Skip to main content

ruma_client_api/admin/
is_user_locked.rs

1//! `GET /_matrix/client/*/admin/lock/{userId}`
2//!
3//! Gets information about the locked 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.18/client-server-api/#get_matrixclientv1adminlockuserid
14
15    use ruma_common::{
16        OwnedUserId,
17        api::{auth_scheme::AccessToken, request, response},
18        metadata,
19    };
20
21    metadata! {
22        method: GET,
23        rate_limited: false,
24        authentication: AccessToken,
25        history: {
26            unstable("uk.timedout.msc4323") => "/_matrix/client/unstable/uk.timedout.msc4323/admin/lock/{user_id}",
27            1.18 => "/_matrix/client/v1/admin/lock/{user_id}",
28        }
29    }
30
31    /// Request type for the `is_user_locked` endpoint.
32    #[request]
33    pub struct Request {
34        /// The user to look up.
35        #[ruma_api(path)]
36        pub user_id: OwnedUserId,
37    }
38
39    /// Response type for the `is_user_locked` endpoint.
40    #[response]
41    pub struct Response {
42        /// Whether the target account is locked.
43        pub locked: bool,
44    }
45
46    impl Request {
47        /// Creates a new `Request` with the given user ID.
48        pub fn new(user_id: OwnedUserId) -> Self {
49            Self { user_id }
50        }
51    }
52
53    impl Response {
54        /// Creates a new `Response` with the given locked status.
55        pub fn new(locked: bool) -> Self {
56            Self { locked }
57        }
58    }
59}