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