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