ruma_federation_api/event/get_room_state.rs
1//! `GET /_matrix/federation/*/state/{roomId}`
2//!
3//! Retrieves a snapshot of a room's state at a given event.
4
5pub mod v1 {
6 //! `/v1/` ([spec])
7 //!
8 //! [spec]: https://spec.matrix.org/latest/server-server-api/#get_matrixfederationv1stateroomid
9
10 use ruma_common::{
11 api::{request, response, Metadata},
12 metadata, OwnedEventId, OwnedRoomId,
13 };
14 use serde_json::value::RawValue as RawJsonValue;
15
16 const METADATA: Metadata = metadata! {
17 method: GET,
18 rate_limited: false,
19 authentication: ServerSignatures,
20 history: {
21 1.0 => "/_matrix/federation/v1/state/:room_id",
22 }
23 };
24
25 /// Request type for the `get_room_state` 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` 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: Vec<Box<RawJsonValue>>,
43
44 /// The fully resolved state of the room at the given event.
45 pub pdus: Vec<Box<RawJsonValue>>,
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 and room state.
57 pub fn new(auth_chain: Vec<Box<RawJsonValue>>, pdus: Vec<Box<RawJsonValue>>) -> Self {
58 Self { auth_chain, pdus }
59 }
60 }
61}