ruma_federation_api/membership/create_join_event/
v1.rs

1//! `/v1/` ([spec])
2//!
3//! [spec]: https://spec.matrix.org/latest/server-server-api/#put_matrixfederationv1send_joinroomideventid
4
5use ruma_common::{
6    api::{request, response},
7    metadata, OwnedEventId, OwnedRoomId,
8};
9use serde::{Deserialize, Serialize};
10use serde_json::value::RawValue as RawJsonValue;
11
12use crate::authentication::ServerSignatures;
13
14metadata! {
15    method: PUT,
16    rate_limited: false,
17    authentication: ServerSignatures,
18    path: "/_matrix/federation/v1/send_join/{room_id}/{event_id}",
19}
20
21/// Request type for the `create_join_event` endpoint.
22#[request]
23#[deprecated = "Since Matrix Server-Server API r0.1.4. Use the v2 endpoint instead."]
24pub struct Request {
25    /// The room ID that is about to be joined.
26    ///
27    /// Do not use this. Instead, use the `room_id` field inside the PDU.
28    #[ruma_api(path)]
29    pub room_id: OwnedRoomId,
30
31    /// The event ID for the join event.
32    #[ruma_api(path)]
33    pub event_id: OwnedEventId,
34
35    /// The PDU.
36    #[ruma_api(body)]
37    pub pdu: Box<RawJsonValue>,
38}
39
40/// Response type for the `create_join_event` endpoint.
41#[response]
42#[deprecated = "Since Matrix Server-Server API r0.1.4. Use the v2 endpoint instead."]
43pub struct Response {
44    /// Full state and auth chain of the room prior to the join event.
45    #[ruma_api(body)]
46    #[serde(with = "crate::serde::v1_pdu")]
47    pub room_state: RoomState,
48}
49
50#[allow(deprecated)]
51impl Request {
52    /// Creates a new `Request` from the given room ID, event ID and PDU.
53    pub fn new(room_id: OwnedRoomId, event_id: OwnedEventId, pdu: Box<RawJsonValue>) -> Self {
54        Self { room_id, event_id, pdu }
55    }
56}
57
58#[allow(deprecated)]
59impl Response {
60    /// Creates a new `Response` with the given room state.
61    pub fn new(room_state: RoomState) -> Self {
62        Self { room_state }
63    }
64}
65
66/// Full state of the room.
67#[derive(Clone, Debug, Default, Deserialize, Serialize)]
68#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
69pub struct RoomState {
70    /// The full set of authorization events that make up the state of the room,
71    /// and their authorization events, recursively.
72    pub auth_chain: Vec<Box<RawJsonValue>>,
73
74    /// The room state.
75    pub state: Vec<Box<RawJsonValue>>,
76
77    /// The signed copy of the membership event sent to other servers by the
78    /// resident server, including the resident server's signature.
79    ///
80    /// Required if the room version supports restricted join rules.
81    #[serde(skip_serializing_if = "Option::is_none")]
82    pub event: Option<Box<RawJsonValue>>,
83}
84
85impl RoomState {
86    /// Creates an empty `RoomState`.
87    pub fn new() -> Self {
88        Self::default()
89    }
90}