Skip to main content

ruma_client_api/
membership.rs

1//! Endpoints for room membership.
2
3pub mod ban_user;
4pub mod forget_room;
5pub mod get_member_events;
6pub mod invite_user;
7pub mod join_room_by_id;
8pub mod join_room_by_id_or_alias;
9pub mod joined_members;
10pub mod joined_rooms;
11pub mod kick_user;
12pub mod leave_room;
13pub mod mutual_rooms;
14pub mod unban_user;
15
16use ruma_common::{OwnedUserId, ServerSignatures, thirdparty::Medium};
17use serde::{Deserialize, Serialize};
18
19/// A signature of an `m.third_party_invite` token to prove that this user owns a third party
20/// identity which has been invited to the room.
21#[derive(Clone, Debug, Deserialize, Serialize)]
22#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
23pub struct ThirdPartySigned {
24    /// The Matrix ID of the user who issued the invite.
25    pub sender: OwnedUserId,
26
27    /// The Matrix ID of the invitee.
28    pub mxid: OwnedUserId,
29
30    /// The state key of the `m.third_party_invite` event.
31    pub token: String,
32
33    /// A signatures object containing a signature of the entire signed object.
34    pub signatures: ServerSignatures,
35}
36
37impl ThirdPartySigned {
38    /// Creates a new `ThirdPartySigned` from the given sender and invitee user IDs, state key token
39    /// and signatures.
40    pub fn new(
41        sender: OwnedUserId,
42        mxid: OwnedUserId,
43        token: String,
44        signatures: ServerSignatures,
45    ) -> Self {
46        Self { sender, mxid, token, signatures }
47    }
48}
49
50/// Represents third party IDs to invite to the room.
51///
52/// To create an instance of this type, first create a `Invite3pidInit` and convert it via
53/// `Invite3pid::from` / `.into()`.
54#[derive(Clone, Debug, Deserialize, Serialize)]
55#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
56pub struct Invite3pid {
57    /// Hostname and port of identity server to be used for account lookups.
58    pub id_server: String,
59
60    /// An access token registered with the identity server.
61    pub id_access_token: String,
62
63    /// Type of third party ID.
64    pub medium: Medium,
65
66    /// Third party identifier.
67    pub address: String,
68}
69
70/// Initial set of fields of `Invite3pid`.
71///
72/// This struct will not be updated even if additional fields are added to `Invite3pid` in a new
73/// (non-breaking) release of the Matrix specification.
74#[derive(Debug)]
75#[allow(clippy::exhaustive_structs)]
76pub struct Invite3pidInit {
77    /// Hostname and port of identity server to be used for account lookups.
78    pub id_server: String,
79
80    /// An access token registered with the identity server.
81    pub id_access_token: String,
82
83    /// Type of third party ID.
84    pub medium: Medium,
85
86    /// Third party identifier.
87    pub address: String,
88}
89
90impl From<Invite3pidInit> for Invite3pid {
91    fn from(init: Invite3pidInit) -> Self {
92        let Invite3pidInit { id_server, id_access_token, medium, address } = init;
93        Self { id_server, id_access_token, medium, address }
94    }
95}