1//! `/v1/` ([spec])
2//!
3//! [spec]: https://spec.matrix.org/latest/server-server-api/#put_matrixfederationv1send_joinroomideventid
45use ruma_common::{
6 api::{request, response, Metadata},
7 metadata, OwnedEventId, OwnedRoomId,
8};
9use serde::{Deserialize, Serialize};
10use serde_json::value::RawValue as RawJsonValue;
1112const METADATA: Metadata = metadata! {
13 method: PUT,
14 rate_limited: false,
15 authentication: ServerSignatures,
16 history: {
171.0 => "/_matrix/federation/v1/send_join/:room_id/:event_id",
181.0 => deprecated,
19 }
20};
2122/// 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)]
30pub room_id: OwnedRoomId,
3132/// The event ID for the join event.
33#[ruma_api(path)]
34pub event_id: OwnedEventId,
3536/// The PDU.
37#[ruma_api(body)]
38pub pdu: Box<RawJsonValue>,
39}
4041/// 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")]
48pub room_state: RoomState,
49}
5051#[allow(deprecated)]
52impl Request {
53/// Creates a new `Request` from the given room ID, event ID and PDU.
54pub fn new(room_id: OwnedRoomId, event_id: OwnedEventId, pdu: Box<RawJsonValue>) -> Self {
55Self { room_id, event_id, pdu }
56 }
57}
5859#[allow(deprecated)]
60impl Response {
61/// Creates a new `Response` with the given room state.
62pub fn new(room_state: RoomState) -> Self {
63Self { room_state }
64 }
65}
6667/// 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.
73pub auth_chain: Vec<Box<RawJsonValue>>,
7475/// The room state.
76pub state: Vec<Box<RawJsonValue>>,
7778/// 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")]
83pub event: Option<Box<RawJsonValue>>,
84}
8586impl RoomState {
87/// Creates an empty `RoomState`.
88pub fn new() -> Self {
89Self::default()
90 }
91}