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