ruma_federation_api/membership/prepare_knock_event/
v1.rs

1//! `/v1/` ([spec])
2//!
3//! [spec]: https://spec.matrix.org/latest/server-server-api/#get_matrixfederationv1make_knockroomiduserid
4
5use ruma_common::{
6    api::{request, response},
7    metadata, OwnedRoomId, OwnedUserId, RoomVersionId,
8};
9use serde_json::value::RawValue as RawJsonValue;
10
11use crate::authentication::ServerSignatures;
12
13metadata! {
14    method: GET,
15    rate_limited: false,
16    authentication: ServerSignatures,
17    path: "/_matrix/federation/v1/make_knock/{room_id}/{user_id}",
18}
19
20/// Request type for the `create_knock_event_template` 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 user ID the knock event will be for.
28    #[ruma_api(path)]
29    pub user_id: OwnedUserId,
30
31    /// The room versions the sending has support for.
32    ///
33    /// Defaults to `vec![RoomVersionId::V1]`.
34    #[ruma_api(query)]
35    pub ver: Vec<RoomVersionId>,
36}
37
38/// Response type for the `create_knock_event_template` endpoint.
39#[response]
40pub struct Response {
41    /// The version of the room where the server is trying to knock.
42    pub room_version: RoomVersionId,
43
44    /// An unsigned template event.
45    ///
46    /// May differ between room versions.
47    pub event: Box<RawJsonValue>,
48}
49
50impl Request {
51    /// Creates a `Request` with the given room ID and user ID.
52    pub fn new(room_id: OwnedRoomId, user_id: OwnedUserId) -> Self {
53        Self { room_id, user_id, ver: vec![RoomVersionId::V1] }
54    }
55}
56
57impl Response {
58    /// Creates a new `Response` with the given room version ID and event.
59    pub fn new(room_version: RoomVersionId, event: Box<RawJsonValue>) -> Self {
60        Self { room_version, event }
61    }
62}