ruma_client_api/membership/
join_room_by_id.rs

1//! `POST /_matrix/client/*/rooms/{roomId}/join`
2//!
3//! Join a room using its ID.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#post_matrixclientv3roomsroomidjoin
9
10    use ruma_common::{
11        OwnedRoomId,
12        api::{auth_scheme::AccessToken, request, response},
13        metadata,
14    };
15
16    use crate::membership::ThirdPartySigned;
17
18    metadata! {
19        method: POST,
20        rate_limited: true,
21        authentication: AccessToken,
22        history: {
23            1.0 => "/_matrix/client/r0/rooms/{room_id}/join",
24            1.1 => "/_matrix/client/v3/rooms/{room_id}/join",
25        }
26    }
27
28    /// Request type for the `join_room_by_id` endpoint.
29    #[request(error = crate::Error)]
30    pub struct Request {
31        /// The room where the user should be invited.
32        #[ruma_api(path)]
33        pub room_id: OwnedRoomId,
34
35        /// The signature of a `m.third_party_invite` token to prove that this user owns a third
36        /// party identity which has been invited to the room.
37        #[serde(skip_serializing_if = "Option::is_none")]
38        pub third_party_signed: Option<ThirdPartySigned>,
39
40        /// Optional reason for joining the room.
41        #[serde(skip_serializing_if = "Option::is_none")]
42        pub reason: Option<String>,
43    }
44
45    /// Response type for the `join_room_by_id` endpoint.
46    #[response(error = crate::Error)]
47    pub struct Response {
48        /// The room that the user joined.
49        pub room_id: OwnedRoomId,
50    }
51
52    impl Request {
53        /// Creates a new `Request` with the given room id.
54        pub fn new(room_id: OwnedRoomId) -> Self {
55            Self { room_id, third_party_signed: None, reason: None }
56        }
57    }
58
59    impl Response {
60        /// Creates a new `Response` with the given room id.
61        pub fn new(room_id: OwnedRoomId) -> Self {
62            Self { room_id }
63        }
64    }
65}