Skip to main content

ruma_client_api/admin/
is_user_suspended.rs

1//! `GET /_matrix/client/*/admin/suspend/{userId}`
2//!
3//! Gets information about the suspended status of a particular server-local user.
4//!
5//! The user calling this endpoint MUST be a server admin.
6//!
7//! In order to prevent user enumeration, servers MUST ensure that authorization is checked prior to
8//! trying to do account lookups.
9
10pub mod v1 {
11    //! `/v1/` ([spec])
12    //!
13    //! [spec]: https://spec.matrix.org/v1.19/client-server-api/#get_matrixclientv1adminsuspenduserid
14
15    use ruma_common::{
16        OwnedUserId,
17        api::{OAuthClientScope, auth_scheme::AccessToken, request, response},
18        metadata,
19    };
20
21    metadata! {
22        method: GET,
23        rate_limited: false,
24        authentication: AccessToken,
25        required_client_scopes: [
26            #[cfg(not(feature = "unstable-msc4484"))]
27            OAuthClientScope::ApiFullAccess,
28            #[cfg(feature = "unstable-msc4484")]
29            OAuthClientScope::ServerAdministration,
30        ],
31        history: {
32            unstable("uk.timedout.msc4323") => "/_matrix/client/unstable/uk.timedout.msc4323/admin/suspend/{user_id}",
33            1.18 => "/_matrix/client/v1/admin/suspend/{user_id}",
34        }
35    }
36
37    /// Request type for the `is_user_suspended` endpoint.
38    #[request]
39    pub struct Request {
40        /// The user to look up.
41        #[ruma_api(path)]
42        pub user_id: OwnedUserId,
43    }
44
45    /// Response type for the `is_user_suspended` endpoint.
46    #[response]
47    pub struct Response {
48        /// Whether the target account is suspended.
49        pub suspended: bool,
50    }
51
52    impl Request {
53        /// Creates a new `Request` with the given user ID.
54        pub fn new(user_id: OwnedUserId) -> Self {
55            Self { user_id }
56        }
57    }
58
59    impl Response {
60        /// Creates a new `Response` with the given suspended status.
61        pub fn new(suspended: bool) -> Self {
62            Self { suspended }
63        }
64    }
65}