ruma_client_api/membership/
unban_user.rs

1//! `POST /_matrix/client/*/rooms/{roomId}/unban`
2//!
3//! Unban a user from a room.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#post_matrixclientv3roomsroomidunban
9
10    use ruma_common::{
11        OwnedRoomId, OwnedUserId,
12        api::{auth_scheme::AccessToken, request, response},
13        metadata,
14    };
15
16    metadata! {
17        method: POST,
18        rate_limited: false,
19        authentication: AccessToken,
20        history: {
21            1.0 => "/_matrix/client/r0/rooms/{room_id}/unban",
22            1.1 => "/_matrix/client/v3/rooms/{room_id}/unban",
23        }
24    }
25
26    /// Request type for the `unban_user` endpoint.
27    #[request(error = crate::Error)]
28    pub struct Request {
29        /// The room to unban the user from.
30        #[ruma_api(path)]
31        pub room_id: OwnedRoomId,
32
33        /// The user to unban.
34        pub user_id: OwnedUserId,
35
36        /// Optional reason for unbanning the user.
37        #[serde(skip_serializing_if = "Option::is_none")]
38        pub reason: Option<String>,
39    }
40
41    /// Response type for the `unban_user` endpoint.
42    #[response(error = crate::Error)]
43    #[derive(Default)]
44    pub struct Response {}
45
46    impl Request {
47        /// Creates a new `Request` with the given room id and room id.
48        pub fn new(room_id: OwnedRoomId, user_id: OwnedUserId) -> Self {
49            Self { room_id, user_id, reason: None }
50        }
51    }
52
53    impl Response {
54        /// Creates an empty `Response`.
55        pub fn new() -> Self {
56            Self {}
57        }
58    }
59}