ruma_appservice_api/thirdparty/
get_user_for_user_id.rs

1//! `GET /_matrix/app/*/thirdparty/user`
2//!
3//! Retrieve an array of third party users from a Matrix User ID.
4
5pub mod v1 {
6    //! `/v1/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/application-service-api/#get_matrixappv1thirdpartyuser
9
10    use ruma_common::{
11        OwnedUserId,
12        api::{auth_scheme::AccessToken, request, response},
13        metadata,
14        thirdparty::User,
15    };
16
17    metadata! {
18        method: GET,
19        rate_limited: false,
20        authentication: AccessToken,
21        path: "/_matrix/app/v1/thirdparty/user",
22    }
23
24    /// Request type for the `get_user_for_user_id` endpoint.
25    #[request]
26    pub struct Request {
27        /// The Matrix User ID to look up.
28        #[ruma_api(query)]
29        pub userid: OwnedUserId,
30    }
31
32    /// Response type for the `get_user_for_user_id` endpoint.
33    #[response]
34    pub struct Response {
35        /// List of matched third party users.
36        #[ruma_api(body)]
37        pub users: Vec<User>,
38    }
39
40    impl Request {
41        /// Creates a new `Request` with the given user id.
42        pub fn new(userid: OwnedUserId) -> Self {
43            Self { userid }
44        }
45    }
46
47    impl Response {
48        /// Creates a new `Response` with the given users.
49        pub fn new(users: Vec<User>) -> Self {
50            Self { users }
51        }
52    }
53}