Skip to main content

ruma_identity_service_api/tos/
accept_terms_of_service.rs

1//! `POST /_matrix/identity/*/terms`
2//!
3//! Send acceptance of the terms of service of an identity server.
4
5pub mod v2 {
6    //! `/v2/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/v1.19/identity-service-api/#post_matrixidentityv2terms
9
10    use ruma_common::{
11        api::{request, response},
12        metadata,
13    };
14
15    use crate::IdentityServiceToken;
16
17    metadata! {
18        method: POST,
19        rate_limited: false,
20        authentication: IdentityServiceToken,
21        history: {
22            1.0 => "/_matrix/identity/v2/terms",
23        }
24    }
25
26    /// Request type for the `accept_terms_of_service` endpoint.
27    #[request]
28    pub struct Request {
29        /// The URLs the user is accepting in this request.
30        ///
31        /// An example is `https://example.org/somewhere/terms-2.0-en.html`.
32        pub user_accepts: Vec<String>,
33    }
34
35    /// Response type for the `accept_terms_of_service` endpoint.
36    #[response]
37    #[derive(Default)]
38    pub struct Response {}
39
40    impl Request {
41        /// Creates a new `Request` with the given URLs which the user accepts.
42        pub fn new(user_accepts: Vec<String>) -> Self {
43            Self { user_accepts }
44        }
45    }
46
47    impl Response {
48        /// Creates an empty `Response`.
49        pub fn new() -> Self {
50            Self {}
51        }
52    }
53}