ruma_federation_api/membership/prepare_leave_event.rs
1//! `GET /_matrix/federation/*/make_leave/{roomId}/{userId}`
2//!
3//! Asks the receiving server to return information that the sending server will need to prepare a
4//! leave event to get out of the room.
5
6pub mod v1 {
7 //! `/v1/` ([spec])
8 //!
9 //! [spec]: https://spec.matrix.org/latest/server-server-api/#get_matrixfederationv1make_leaveroomiduserid
10
11 use ruma_common::{
12 OwnedRoomId, OwnedUserId, RoomVersionId,
13 api::{request, response},
14 metadata,
15 };
16 use serde_json::value::RawValue as RawJsonValue;
17
18 use crate::authentication::ServerSignatures;
19
20 metadata! {
21 method: GET,
22 rate_limited: false,
23 authentication: ServerSignatures,
24 path: "/_matrix/federation/v1/make_leave/{room_id}/{user_id}",
25 }
26
27 /// Request type for the `get_leave_event` endpoint.
28 #[request]
29 pub struct Request {
30 /// The room ID that is about to be left.
31 #[ruma_api(path)]
32 pub room_id: OwnedRoomId,
33
34 /// The user ID the leave event will be for.
35 #[ruma_api(path)]
36 pub user_id: OwnedUserId,
37 }
38
39 /// Response type for the `get_leave_event` endpoint.
40 #[response]
41 pub struct Response {
42 /// The version of the room where the server is trying to leave.
43 ///
44 /// If not provided, the room version is assumed to be either "1" or "2".
45 pub room_version: Option<RoomVersionId>,
46
47 /// An unsigned template event.
48 ///
49 /// Note that events have a different format depending on the room version - check the room
50 /// version specification for precise event formats.
51 pub event: Box<RawJsonValue>,
52 }
53
54 impl Request {
55 /// Creates a new `Request` with:
56 /// * the room ID that is about to be left.
57 /// * the user ID the leave event will be for.
58 pub fn new(room_id: OwnedRoomId, user_id: OwnedUserId) -> Self {
59 Self { room_id, user_id }
60 }
61 }
62
63 impl Response {
64 /// Creates a new `Response` with:
65 /// * the version of the room where the server is trying to leave.
66 /// * an unsigned template event.
67 pub fn new(room_version: Option<RoomVersionId>, event: Box<RawJsonValue>) -> Self {
68 Self { room_version, event }
69 }
70 }
71}