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