ruma_client_api/keys/
get_key_changes.rs

1//! `GET /_matrix/client/*/keys/changes`
2//!
3//! Gets a list of users who have updated their device identity keys since a previous sync token.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3keyschanges
9
10    use ruma_common::{
11        OwnedUserId,
12        api::{auth_scheme::AccessToken, request, response},
13        metadata,
14    };
15
16    metadata! {
17        method: GET,
18        rate_limited: false,
19        authentication: AccessToken,
20        history: {
21            1.0 => "/_matrix/client/r0/keys/changes",
22            1.1 => "/_matrix/client/v3/keys/changes",
23        }
24    }
25
26    /// Request type for the `get_key_changes` endpoint.
27    #[request(error = crate::Error)]
28    pub struct Request {
29        /// The desired start point of the list.
30        ///
31        /// Should be the next_batch field from a response to an earlier call to /sync.
32        #[ruma_api(query)]
33        pub from: String,
34
35        /// The desired end point of the list.
36        ///
37        /// Should be the next_batch field from a recent call to /sync - typically the most recent
38        /// such call.
39        #[ruma_api(query)]
40        pub to: String,
41    }
42
43    /// Response type for the `get_key_changes` endpoint.
44    #[response(error = crate::Error)]
45    pub struct Response {
46        /// The Matrix User IDs of all users who updated their device identity keys.
47        pub changed: Vec<OwnedUserId>,
48
49        /// The Matrix User IDs of all users who may have left all the end-to-end
50        /// encrypted rooms they previously shared with the user.
51        pub left: Vec<OwnedUserId>,
52    }
53
54    impl Request {
55        /// Creates a new `Request` with the given start and end points.
56        pub fn new(from: String, to: String) -> Self {
57            Self { from, to }
58        }
59    }
60
61    impl Response {
62        /// Creates a new `Response` with the given changed and left user ID lists.
63        pub fn new(changed: Vec<OwnedUserId>, left: Vec<OwnedUserId>) -> Self {
64            Self { changed, left }
65        }
66    }
67}