ruma_federation_api/event/
get_room_state_ids.rs

1//! `GET /_matrix/federation/*/state_ids/{roomId}`
2//!
3//! Retrieves a snapshot of a room's state at a given event, in the form of event IDs.
4
5pub mod v1 {
6    //! `/v1/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/server-server-api/#get_matrixfederationv1state_idsroomid
9
10    use ruma_common::{
11        OwnedEventId, OwnedRoomId,
12        api::{request, response},
13        metadata,
14    };
15
16    use crate::authentication::ServerSignatures;
17
18    metadata! {
19        method: GET,
20        rate_limited: false,
21        authentication: ServerSignatures,
22        path: "/_matrix/federation/v1/state_ids/{room_id}",
23    }
24
25    /// Request type for the `get_room_state_ids` endpoint.
26    #[request]
27    pub struct Request {
28        /// The room ID to get state for.
29        #[ruma_api(path)]
30        pub room_id: OwnedRoomId,
31
32        /// An event ID in the room to retrieve the state at.
33        #[ruma_api(query)]
34        pub event_id: OwnedEventId,
35    }
36
37    /// Response type for the `get_room_state_ids` endpoint.
38    #[response]
39    pub struct Response {
40        /// The full set of authorization events that make up the state of the
41        /// room, and their authorization events, recursively.
42        pub auth_chain_ids: Vec<OwnedEventId>,
43
44        /// The fully resolved state of the room at the given event.
45        pub pdu_ids: Vec<OwnedEventId>,
46    }
47
48    impl Request {
49        /// Creates a new `Request` with the given event id and room id.
50        pub fn new(event_id: OwnedEventId, room_id: OwnedRoomId) -> Self {
51            Self { room_id, event_id }
52        }
53    }
54
55    impl Response {
56        /// Creates a new `Response` with the given auth chain IDs and room state IDs.
57        pub fn new(auth_chain_ids: Vec<OwnedEventId>, pdu_ids: Vec<OwnedEventId>) -> Self {
58            Self { auth_chain_ids, pdu_ids }
59        }
60    }
61}