ruma_identity_service_api/invitation/
sign_invitation_ed25519.rs

1//! `POST /_matrix/identity/*/sign-ed25519`
2//!
3//! Sign invitation details.
4
5pub mod v2 {
6    //! `/v2/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/identity-service-api/#post_matrixidentityv2sign-ed25519
9
10    use ruma_common::{
11        api::{request, response, Metadata},
12        metadata,
13        serde::Base64,
14        OwnedUserId, ServerSignatures,
15    };
16
17    const METADATA: Metadata = metadata! {
18        method: POST,
19        rate_limited: false,
20        authentication: AccessToken,
21        history: {
22            1.0 => "/_matrix/identity/v2/sign-ed25519",
23        }
24    };
25
26    /// Request type for the `sign_invitation_ed25519` endpoint.
27    #[request]
28    pub struct Request {
29        /// The Matrix user ID of the user accepting the invitation.
30        pub mxid: OwnedUserId,
31
32        /// The token from the call to store-invite.
33        pub token: String,
34
35        /// The private key, encoded as unpadded base64.
36        pub private_key: Base64,
37    }
38
39    /// Response type for the `sign_invitation_ed25519` endpoint.
40    #[response]
41    pub struct Response {
42        /// The Matrix user ID of the user accepting the invitation.
43        pub mxid: OwnedUserId,
44
45        /// The Matrix user ID of the user who sent the invitation.
46        pub sender: OwnedUserId,
47
48        /// The signature of the mxid, sender and token.
49        pub signatures: ServerSignatures,
50
51        /// The token for the invitation.
52        pub token: String,
53    }
54
55    impl Request {
56        /// Creates a `Request` with the given Matrix user ID, token and private_key.
57        pub fn new(mxid: OwnedUserId, token: String, private_key: Base64) -> Self {
58            Self { mxid, token, private_key }
59        }
60    }
61
62    impl Response {
63        /// Creates a `Response` with the given Matrix user ID, sender user ID, signatures and
64        /// token.
65        pub fn new(
66            mxid: OwnedUserId,
67            sender: OwnedUserId,
68            signatures: ServerSignatures,
69            token: String,
70        ) -> Self {
71            Self { mxid, sender, signatures, token }
72        }
73    }
74}