ruma_federation_api/authorization/
get_event_authorization.rs

1//! `GET /_matrix/federation/*/event_auth/{roomId}/{eventId}`
2//!
3//! Get the complete auth chain for a given event.
4
5pub mod v1 {
6    //! `/v1/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/server-server-api/#get_matrixfederationv1event_authroomideventid
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/event_auth/{room_id}/{event_id}",
24    }
25
26    /// Request type for the `get_event_authorization` endpoint.
27    #[request]
28    pub struct Request {
29        /// The room ID to get the auth chain for.
30        #[ruma_api(path)]
31        pub room_id: OwnedRoomId,
32
33        /// The event ID to get the auth chain for.
34        #[ruma_api(path)]
35        pub event_id: OwnedEventId,
36    }
37
38    /// Response type for the `get_event_authorization` endpoint.
39    #[response]
40    pub struct Response {
41        /// The full set of authorization events that make up the state of the room,
42        /// and their authorization events, recursively.
43        pub auth_chain: Vec<Box<RawJsonValue>>,
44    }
45
46    impl Request {
47        /// Creates a new `Request` with the given room id and event id.
48        pub fn new(room_id: OwnedRoomId, event_id: OwnedEventId) -> Self {
49            Self { room_id, event_id }
50        }
51    }
52
53    impl Response {
54        /// Creates a new `Response` with the given auth chain.
55        pub fn new(auth_chain: Vec<Box<RawJsonValue>>) -> Self {
56            Self { auth_chain }
57        }
58    }
59}