Skip to main content

ruma_identity_service_api/authentication/
get_account_information.rs

1//! `GET /_matrix/identity/*/account`
2//!
3//! Get information about what user owns the access token used in the request.
4
5pub mod v2 {
6    //! `/v2/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/v1.19/identity-service-api/#get_matrixidentityv2account
9
10    use ruma_common::{
11        OwnedUserId,
12        api::{request, response},
13        metadata,
14    };
15
16    use crate::IdentityServiceToken;
17
18    metadata! {
19        method: POST,
20        rate_limited: false,
21        authentication: IdentityServiceToken,
22        history: {
23            1.0 => "/_matrix/identity/v2/account",
24        }
25    }
26
27    /// Request type for the `get_account_information` endpoint.
28    #[request]
29    #[derive(Default)]
30    pub struct Request {}
31
32    /// Response type for the `get_account_information` endpoint.
33    #[response]
34    pub struct Response {
35        /// The user ID which registered the token.
36        pub user_id: OwnedUserId,
37    }
38
39    impl Request {
40        /// Creates an empty `Request`.
41        pub fn new() -> Self {
42            Self {}
43        }
44    }
45
46    impl Response {
47        /// Creates a new `Response` with the given `UserId`.
48        pub fn new(user_id: OwnedUserId) -> Self {
49            Self { user_id }
50        }
51    }
52}