diff --git a/ruma-federation-api/CHANGELOG.md b/ruma-federation-api/CHANGELOG.md index ad7086a1..fc2b8253 100644 --- a/ruma-federation-api/CHANGELOG.md +++ b/ruma-federation-api/CHANGELOG.md @@ -25,7 +25,10 @@ Improvements: create_leave_event::{v1, v2}, get_leave_event::v1, }, - thirdparty::bind_callback::v1, + thirdparty::{ + bind_callback::v1, + exchange_invite::v1, + }, ``` # 0.0.3 diff --git a/ruma-federation-api/src/thirdparty.rs b/ruma-federation-api/src/thirdparty.rs index 132fe2ec..e1835785 100644 --- a/ruma-federation-api/src/thirdparty.rs +++ b/ruma-federation-api/src/thirdparty.rs @@ -1,3 +1,4 @@ //! Module for dealing with third party identifiers pub mod bind_callback; +pub mod exchange_invite; diff --git a/ruma-federation-api/src/thirdparty/exchange_invite.rs b/ruma-federation-api/src/thirdparty/exchange_invite.rs new file mode 100644 index 00000000..4b3999b9 --- /dev/null +++ b/ruma-federation-api/src/thirdparty/exchange_invite.rs @@ -0,0 +1,7 @@ +//! The receiving server will verify the partial `m.room.member` event given in the request body. +//! If valid, the receiving server will issue an invite as per the [Inviting to a room] section +//! before returning a response to this request. +//! +//! [Inviting to a room]: https://matrix.org/docs/spec/server_server/r0.1.4#inviting-to-a-room + +pub mod v1; diff --git a/ruma-federation-api/src/thirdparty/exchange_invite/v1.rs b/ruma-federation-api/src/thirdparty/exchange_invite/v1.rs new file mode 100644 index 00000000..525e1080 --- /dev/null +++ b/ruma-federation-api/src/thirdparty/exchange_invite/v1.rs @@ -0,0 +1,57 @@ +//! [PUT /_matrix/federation/v1/exchange_third_party_invite/{roomId}](https://matrix.org/docs/spec/server_server/r0.1.4#put-matrix-federation-v1-exchange-third-party-invite-roomid) + +use ruma_api::ruma_api; +use ruma_events::{room::member::ThirdPartyInvite, EventType}; +use ruma_identifiers::{RoomId, UserId}; + +ruma_api! { + metadata: { + description: "The receiving server will verify the partial m.room.member event given in the request body.", + method: PUT, + name: "exchange_invite", + path: "/_matrix/federation/v1/exchange_third_party_invite/:room_id", + rate_limited: false, + authentication: AccessToken, + } + + request: { + /// The room ID to exchange a third party invite in. + #[ruma_api(path)] + pub room_id: &'a RoomId, + + /// The event type. Must be `m.room.member`. + #[serde(rename = "type")] + pub kind: EventType, + + /// The user ID of the user who sent the original invite event. + pub sender: &'a UserId, + + /// The user ID of the invited user. + pub state_key: &'a UserId, + + /// The content of the invite event. + pub content: &'a ThirdPartyInvite, + } + + #[derive(Default)] + response: {} +} + +impl<'a> Request<'a> { + /// Creates a new `Request` for a third party invite exchange + pub fn new( + room_id: &'a RoomId, + sender: &'a UserId, + state_key: &'a UserId, + content: &'a ThirdPartyInvite, + ) -> Self { + Self { room_id, kind: EventType::RoomMember, sender, state_key, content } + } +} + +impl Response { + /// Creates a new `Response`. + pub fn new() -> Self { + Self + } +}