ruma_federation_api/membership/
create_knock_event.rs

1//! `PUT /_matrix/federation/*/send_knock/{roomId}/{eventId}`
2//!
3//! Submits a signed knock event to the resident homeserver for it to accept into the room's graph.
4
5pub mod v1 {
6    //! `/v1/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/server-server-api/#put_matrixfederationv1send_knockroomideventid
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    use crate::membership::RawStrippedState;
17
18    const METADATA: Metadata = metadata! {
19        method: PUT,
20        rate_limited: false,
21        authentication: ServerSignatures,
22        history: {
23            unstable => "/_matrix/federation/unstable/xyz.amorgan.knock/send_knock/{room_id}/{event_id}",
24            1.1 => "/_matrix/federation/v1/send_knock/{room_id}/{event_id}",
25        }
26    };
27
28    /// Request type for the `send_knock` endpoint.
29    #[request]
30    pub struct Request {
31        /// The room ID that should receive the knock.
32        #[ruma_api(path)]
33        pub room_id: OwnedRoomId,
34
35        /// The event ID for the knock event.
36        #[ruma_api(path)]
37        pub event_id: OwnedEventId,
38
39        /// The PDU.
40        #[ruma_api(body)]
41        pub pdu: Box<RawJsonValue>,
42    }
43
44    /// Response type for the `send_knock` endpoint.
45    #[response]
46    pub struct Response {
47        /// State events providing public room metadata.
48        pub knock_room_state: Vec<RawStrippedState>,
49    }
50
51    impl Request {
52        /// Creates a new `Request` with the given room ID, event ID and knock event.
53        pub fn new(room_id: OwnedRoomId, event_id: OwnedEventId, pdu: Box<RawJsonValue>) -> Self {
54            Self { room_id, event_id, pdu }
55        }
56    }
57
58    impl Response {
59        /// Creates a new `Response` with the given public room metadata state events.
60        pub fn new(knock_room_state: Vec<RawStrippedState>) -> Self {
61            Self { knock_room_state }
62        }
63    }
64}