ruma_federation_api/membership/create_knock_event/
v1.rs

1//! `/v1/` ([spec])
2//!
3//! [spec]: https://spec.matrix.org/latest/server-server-api/#put_matrixfederationv1send_knockroomideventid
4
5use ruma_common::{
6    OwnedEventId, OwnedRoomId,
7    api::{request, response},
8    metadata,
9};
10use serde_json::value::RawValue as RawJsonValue;
11
12use crate::{authentication::ServerSignatures, membership::RawStrippedState};
13
14metadata! {
15    method: PUT,
16    rate_limited: false,
17    authentication: ServerSignatures,
18    path: "/_matrix/federation/v1/send_knock/{room_id}/{event_id}",
19}
20
21/// Request type for the `send_knock` endpoint.
22#[request]
23pub struct Request {
24    /// The room ID that should receive the knock.
25    #[ruma_api(path)]
26    pub room_id: OwnedRoomId,
27
28    /// The event ID for the knock event.
29    #[ruma_api(path)]
30    pub event_id: OwnedEventId,
31
32    /// The PDU.
33    #[ruma_api(body)]
34    pub pdu: Box<RawJsonValue>,
35}
36
37/// Response type for the `send_knock` endpoint.
38#[response]
39pub struct Response {
40    /// State events providing public room metadata.
41    pub knock_room_state: Vec<RawStrippedState>,
42}
43
44impl Request {
45    /// Creates a new `Request` with the given room ID, event ID and knock event.
46    pub fn new(room_id: OwnedRoomId, event_id: OwnedEventId, pdu: Box<RawJsonValue>) -> Self {
47        Self { room_id, event_id, pdu }
48    }
49}
50
51impl Response {
52    /// Creates a new `Response` with the given public room metadata state events.
53    pub fn new(knock_room_state: Vec<RawStrippedState>) -> Self {
54        Self { knock_room_state }
55    }
56}