Skip to main content

ruma_federation_api/query/
get_presence_recipients.rs

1//! `GET /_matrix/federation/*/query/presence_recipients`
2pub mod msc4495 {
3    //! [`/unstable/org.continuwuity.presence_v2.msc4495/`][MSC4495]
4    //!
5    //! [MSC4495]: https://github.com/matrix-org/matrix-spec-proposals/pull/4495
6
7    use js_int::Int;
8    use ruma_common::{
9        OwnedUserId,
10        api::{request, response},
11        metadata,
12    };
13
14    use crate::authentication::ServerSignatures;
15
16    metadata! {
17        method: GET,
18        rate_limited: false,
19        authentication: ServerSignatures,
20        path: "/_matrix/federation/unstable/org.continuwuity.presence_v2.msc4495/query/presence_recipients",
21    }
22
23    /// Request type for the `get_presence_recipients` endpoint.
24    #[request]
25    pub struct Request {
26        /// The user ID to query. Must be local to the queried server.
27        #[ruma_api(query)]
28        pub user_id: OwnedUserId,
29    }
30
31    impl Request {
32        /// Creates a new `Request` with the given user ID.
33        pub fn new(user_id: OwnedUserId) -> Self {
34            Self { user_id }
35        }
36    }
37
38    /// Response type for the `get_presence_recipients` endpoint.
39    #[response]
40    pub struct Response {
41        /// A unique identifier for the user's current recipient user set.
42        pub stream_id: Int,
43
44        /// An array of local recipients the user intends to push presence to.
45        pub recipients: Vec<OwnedUserId>,
46    }
47
48    impl Response {
49        /// Creates a new `Response` with the given stream ID and recipients.
50        pub fn new(stream_id: Int, recipients: Vec<OwnedUserId>) -> Self {
51            Self { stream_id, recipients }
52        }
53    }
54}