From c19bcaab313b64666fb02260dfb9e55a7d70584b Mon Sep 17 00:00:00 2001 From: skim Date: Fri, 10 Jul 2020 11:36:46 -0700 Subject: [PATCH] Add get event auth endpoint --- ruma-federation-api/CHANGELOG.md | 1 + ruma-federation-api/src/authorization.rs | 3 ++ .../get_event_authorization/mod.rs | 2 ++ .../get_event_authorization/v1.rs | 32 +++++++++++++++++++ ruma-federation-api/src/lib.rs | 1 + 5 files changed, 39 insertions(+) create mode 100644 ruma-federation-api/src/authorization.rs create mode 100644 ruma-federation-api/src/authorization/get_event_authorization/mod.rs create mode 100644 ruma-federation-api/src/authorization/get_event_authorization/v1.rs diff --git a/ruma-federation-api/CHANGELOG.md b/ruma-federation-api/CHANGELOG.md index d910ff92..8ea78692 100644 --- a/ruma-federation-api/CHANGELOG.md +++ b/ruma-federation-api/CHANGELOG.md @@ -8,6 +8,7 @@ Improvements: * Add endpoints: ``` + authorization::get_event_authorization::v1, directory::get_public_rooms::v1, discovery::{ discover_homeserver, diff --git a/ruma-federation-api/src/authorization.rs b/ruma-federation-api/src/authorization.rs new file mode 100644 index 00000000..83dac60c --- /dev/null +++ b/ruma-federation-api/src/authorization.rs @@ -0,0 +1,3 @@ +//! Endpoints to retrieve the complete auth chain for a given event. + +pub mod get_event_authorization; diff --git a/ruma-federation-api/src/authorization/get_event_authorization/mod.rs b/ruma-federation-api/src/authorization/get_event_authorization/mod.rs new file mode 100644 index 00000000..d6f98a82 --- /dev/null +++ b/ruma-federation-api/src/authorization/get_event_authorization/mod.rs @@ -0,0 +1,2 @@ +//! Endpoint to retrieve the complete auth chain for a given event. +pub mod v1; diff --git a/ruma-federation-api/src/authorization/get_event_authorization/v1.rs b/ruma-federation-api/src/authorization/get_event_authorization/v1.rs new file mode 100644 index 00000000..a70bc828 --- /dev/null +++ b/ruma-federation-api/src/authorization/get_event_authorization/v1.rs @@ -0,0 +1,32 @@ +//! [GET /_matrix/federation/v1/event_auth/{roomId}/{eventId}](https://matrix.org/docs/spec/server_server/r0.1.4#get-matrix-federation-v1-event-auth-roomid-eventid) + +use ruma_api::ruma_api; +use ruma_events::pdu::Pdu; +use ruma_identifiers::{EventId, RoomId}; + +ruma_api! { + metadata: { + description: "Retrieves the complete auth chain for a given event.", + name: "get_event_authorization", + method: GET, + path: "/_matrix/federation/v1/event_auth/:room_id/:event_id", + rate_limited: false, + requires_authentication: true, + } + + request: { + /// The room ID to get the auth chain for. + #[ruma_api(path)] + pub room_id: RoomId, + + /// The event ID to get the auth chain for. + #[ruma_api(path)] + pub event_id: EventId, + } + + response: { + /// The full set of authorization events that make up the state of the room, + /// and their authorization events, recursively. + pub auth_chain: Vec, + } +} diff --git a/ruma-federation-api/src/lib.rs b/ruma-federation-api/src/lib.rs index 986a4f07..29c17d62 100644 --- a/ruma-federation-api/src/lib.rs +++ b/ruma-federation-api/src/lib.rs @@ -4,6 +4,7 @@ mod serde; +pub mod authorization; pub mod directory; pub mod discovery; pub mod membership;