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        api::{request, response, Metadata},
12        metadata, OwnedEventId, OwnedRoomId,
13    };
14
15    const METADATA: Metadata = metadata! {
16        method: GET,
17        rate_limited: false,
18        authentication: ServerSignatures,
19        history: {
20            1.0 => "/_matrix/federation/v1/state_ids/:room_id",
21        }
22    };
23
24    /// Request type for the `get_room_state_ids` endpoint.
25    #[request]
26    pub struct Request {
27        /// The room ID to get state for.
28        #[ruma_api(path)]
29        pub room_id: OwnedRoomId,
30
31        /// An event ID in the room to retrieve the state at.
32        #[ruma_api(query)]
33        pub event_id: OwnedEventId,
34    }
35
36    /// Response type for the `get_room_state_ids` endpoint.
37    #[response]
38    pub struct Response {
39        /// The full set of authorization events that make up the state of the
40        /// room, and their authorization events, recursively.
41        pub auth_chain_ids: Vec<OwnedEventId>,
42
43        /// The fully resolved state of the room at the given event.
44        pub pdu_ids: Vec<OwnedEventId>,
45    }
46
47    impl Request {
48        /// Creates a new `Request` with the given event id and room id.
49        pub fn new(event_id: OwnedEventId, room_id: OwnedRoomId) -> Self {
50            Self { room_id, event_id }
51        }
52    }
53
54    impl Response {
55        /// Creates a new `Response` with the given auth chain IDs and room state IDs.
56        pub fn new(auth_chain_ids: Vec<OwnedEventId>, pdu_ids: Vec<OwnedEventId>) -> Self {
57            Self { auth_chain_ids, pdu_ids }
58        }
59    }
60}