Skip to main content

ruma_appservice_api/query/
query_user_id.rs

1//! `GET /_matrix/app/*/users/{userId}`
2//!
3//! Endpoint to query the existence of a given user ID.
4
5pub mod v1 {
6    //! `/v1/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/v1.19/application-service-api/#get_matrixappv1usersuserid
9
10    use ruma_common::{
11        OwnedUserId,
12        api::{request, response},
13        metadata,
14    };
15
16    use crate::HomeserverToken;
17
18    metadata! {
19        method: GET,
20        rate_limited: false,
21        authentication: HomeserverToken,
22        path: "/_matrix/app/v1/users/{user_id}",
23    }
24
25    /// Request type for the `query_user_id` endpoint.
26    #[request]
27    pub struct Request {
28        /// The user ID being queried.
29        #[ruma_api(path)]
30        pub user_id: OwnedUserId,
31    }
32
33    /// Response type for the `query_user_id` endpoint.
34    #[response]
35    #[derive(Default)]
36    pub struct Response {}
37
38    impl Request {
39        /// Creates a new `Request` with the given user id.
40        pub fn new(user_id: OwnedUserId) -> Self {
41            Self { user_id }
42        }
43    }
44
45    impl Response {
46        /// Creates an empty `Response`.
47        pub fn new() -> Self {
48            Self {}
49        }
50    }
51}