ruma_federation_api/membership/prepare_knock_event/
unstable.rs1use ruma_common::{
6 api::{path_builder::SinglePath, request, response, Metadata},
7 OwnedRoomId, OwnedUserId, RoomVersionId,
8};
9use serde_json::value::RawValue as RawJsonValue;
10
11#[request]
13pub struct Request {
14 #[ruma_api(path)]
16 pub room_id: OwnedRoomId,
17
18 #[ruma_api(path)]
20 pub user_id: OwnedUserId,
21
22 #[ruma_api(query)]
26 pub ver: Vec<RoomVersionId>,
27}
28
29impl Request {
30 pub fn new(room_id: OwnedRoomId, user_id: OwnedUserId) -> Self {
32 Self { room_id, user_id, ver: vec![RoomVersionId::V1] }
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/make_knock/{room_id}/{user_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, user_id, ver } = value;
49 Self { room_id, user_id, ver }
50 }
51}
52
53impl From<Request> for super::v1::Request {
54 fn from(value: Request) -> Self {
55 let Request { room_id, user_id, ver } = value;
56 Self { room_id, user_id, ver }
57 }
58}
59
60#[response]
62pub struct Response {
63 pub room_version: RoomVersionId,
65
66 pub event: Box<RawJsonValue>,
70}
71
72impl Response {
73 pub fn new(room_version: RoomVersionId, event: Box<RawJsonValue>) -> Self {
75 Self { room_version, event }
76 }
77}
78
79impl From<super::v1::Response> for Response {
80 fn from(value: super::v1::Response) -> Self {
81 let super::v1::Response { room_version, event } = value;
82 Self { room_version, event }
83 }
84}
85
86impl From<Response> for super::v1::Response {
87 fn from(value: Response) -> Self {
88 let Response { room_version, event } = value;
89 Self { room_version, event }
90 }
91}