ruma_federation_api/membership/create_leave_event/
v1.rs

1//! `/v1/` ([spec])
2//!
3//! [spec]: https://spec.matrix.org/latest/server-server-api/#put_matrixfederationv1send_leaveroomideventid
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_leave/{room_id}/{event_id}",
19}
20
21/// Request type for the `create_leave_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 left.
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 leave 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_leave_event` endpoint.
41#[response]
42#[derive(Default)]
43#[deprecated = "Since Matrix Server-Server API r0.1.4. Use the v2 endpoint instead."]
44pub struct Response {
45    /// An empty object.
46    ///
47    /// Indicates that the event was accepted into the event graph.
48    #[ruma_api(body)]
49    #[serde(with = "crate::serde::v1_pdu")]
50    pub empty: Empty,
51}
52
53#[allow(deprecated)]
54impl Request {
55    /// Creates a new `Request` from the given room ID, event ID and PDU.
56    pub fn new(room_id: OwnedRoomId, event_id: OwnedEventId, pdu: Box<RawJsonValue>) -> Self {
57        Self { room_id, event_id, pdu }
58    }
59}
60
61#[allow(deprecated)]
62impl Response {
63    /// Creates an empty `Response`.
64    pub fn new() -> Self {
65        Self { empty: Empty {} }
66    }
67}
68
69/// An empty object.
70#[derive(Clone, Debug, Default, Deserialize, Serialize)]
71#[allow(clippy::exhaustive_structs)]
72pub struct Empty {}
73
74impl Empty {
75    /// Create a new `Empty`.
76    pub fn new() -> Self {
77        Self {}
78    }
79}