Skip to main content

ruma_federation_api/query/
get_edu_types.rs

1//! GET `/_matrix/federation/*/query/edutypes`
2//!
3//! Determine what types of EDUs a server wishes to receive.
4
5pub mod unstable {
6    //! `/unstable/io.fsky.vel/edutypes` ([MSC])
7    //!
8    //! [MSC]: https://github.com/matrix-org/matrix-spec-proposals/pull/4373
9
10    use ruma_common::{
11        api::{auth_scheme::NoAuthentication, request, response},
12        metadata,
13    };
14
15    metadata! {
16        method: GET,
17        rate_limited: false,
18        authentication: NoAuthentication,
19        path: "/_matrix/federation/unstable/io.fsky.vel/edutypes"
20    }
21
22    /// Request type for the `edutypes` endpoint.
23    #[request]
24    #[derive(Default)]
25    pub struct Request {}
26
27    /// Response type for the `edutypes` endpoint.
28    #[response]
29    pub struct Response {
30        /// Whether presence EDUs should be sent/received
31        #[serde(rename = "m.presence", default = "ruma_common::serde::default_true")]
32        pub presence: bool,
33
34        /// Whether read receipt EDUs should be sent/received
35        #[serde(rename = "m.receipt", default = "ruma_common::serde::default_true")]
36        pub receipt: bool,
37
38        /// Whether typing EDUs should be sent/received
39        #[serde(rename = "m.typing", default = "ruma_common::serde::default_true")]
40        pub typing: bool,
41    }
42
43    impl Request {
44        /// Creates a new `Request` with the given event id.
45        pub fn new() -> Self {
46            Self::default()
47        }
48    }
49
50    impl Response {
51        /// Creates a new `Response` with all EDU flags set to `true`.
52        pub fn new() -> Self {
53            Self::default()
54        }
55    }
56
57    impl Default for Response {
58        fn default() -> Self {
59            Self { presence: true, receipt: true, typing: true }
60        }
61    }
62}