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 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/event_auth/:room_id/:event_id",
22 }
23 };
24
25 /// Request type for the `get_event_authorization` endpoint.
26 #[request]
27 pub struct Request {
28 /// The room ID to get the auth chain for.
29 #[ruma_api(path)]
30 pub room_id: OwnedRoomId,
31
32 /// The event ID to get the auth chain for.
33 #[ruma_api(path)]
34 pub event_id: OwnedEventId,
35 }
36
37 /// Response type for the `get_event_authorization` endpoint.
38 #[response]
39 pub struct Response {
40 /// The full set of authorization events that make up the state of the room,
41 /// and their authorization events, recursively.
42 pub auth_chain: Vec<Box<RawJsonValue>>,
43 }
44
45 impl Request {
46 /// Creates a new `Request` with the given room id and event id.
47 pub fn new(room_id: OwnedRoomId, event_id: OwnedEventId) -> Self {
48 Self { room_id, event_id }
49 }
50 }
51
52 impl Response {
53 /// Creates a new `Response` with the given auth chain.
54 pub fn new(auth_chain: Vec<Box<RawJsonValue>>) -> Self {
55 Self { auth_chain }
56 }
57 }
58}