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