ruma_federation_api/membership/create_knock_event/
unstable.rs1use ruma_common::{
6 api::{path_builder::SinglePath, request, response, Metadata},
7 OwnedEventId, OwnedRoomId,
8};
9use serde_json::value::RawValue as RawJsonValue;
10
11use crate::membership::RawStrippedState;
12
13#[request]
15pub struct Request {
16 #[ruma_api(path)]
18 pub room_id: OwnedRoomId,
19
20 #[ruma_api(path)]
22 pub event_id: OwnedEventId,
23
24 #[ruma_api(body)]
26 pub pdu: Box<RawJsonValue>,
27}
28
29impl Request {
30 pub fn new(room_id: OwnedRoomId, event_id: OwnedEventId, pdu: Box<RawJsonValue>) -> Self {
32 Self { room_id, event_id, pdu }
33 }
34}
35
36impl Metadata for Request {
37 const METHOD: http::Method = super::v1::Request::METHOD;
38 const RATE_LIMITED: bool = super::v1::Request::RATE_LIMITED;
39 type Authentication = <super::v1::Request as Metadata>::Authentication;
40 type PathBuilder = <super::v1::Request as Metadata>::PathBuilder;
41 const PATH_BUILDER: Self::PathBuilder = SinglePath::new(
42 "/_matrix/federation/unstable/xyz.amorgan.knock/send_knock/{room_id}/{event_id}",
43 );
44}
45
46impl From<super::v1::Request> for Request {
47 fn from(value: super::v1::Request) -> Self {
48 let super::v1::Request { room_id, event_id, pdu } = value;
49 Self { room_id, event_id, pdu }
50 }
51}
52
53impl From<Request> for super::v1::Request {
54 fn from(value: Request) -> Self {
55 let Request { room_id, event_id, pdu } = value;
56 Self { room_id, event_id, pdu }
57 }
58}
59
60#[response]
62pub struct Response {
63 pub knock_room_state: Vec<RawStrippedState>,
65}
66
67impl Response {
68 pub fn new(knock_room_state: Vec<RawStrippedState>) -> Self {
70 Self { knock_room_state }
71 }
72}
73
74impl From<super::v1::Response> for Response {
75 fn from(value: super::v1::Response) -> Self {
76 let super::v1::Response { knock_room_state } = value;
77 Self { knock_room_state }
78 }
79}
80
81impl From<Response> for super::v1::Response {
82 fn from(value: Response) -> Self {
83 let Response { knock_room_state } = value;
84 Self { knock_room_state }
85 }
86}