1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
use js_int::UInt;
use ruma_api::ruma_api;
use ruma_common::MilliSecondsSinceUnixEpoch;
use ruma_events::{room::member::MemberEventContent, EventType};
use ruma_identifiers::{EventId, RoomId, ServerName, UserId};
use ruma_serde::Raw;
use serde::{Deserialize, Serialize};
ruma_api! {
metadata: {
description: "Submits a signed leave event to the receiving server for it to accept it into the room's graph.",
name: "create_leave_event",
method: PUT,
path: "/_matrix/federation/v1/send_leave/:room_id/:event_id",
rate_limited: false,
authentication: ServerSignatures,
}
request: {
#[ruma_api(path)]
pub room_id: &'a RoomId,
#[ruma_api(path)]
pub event_id: &'a EventId,
#[ruma_api(query)]
pub sender: &'a UserId,
#[ruma_api(query)]
pub origin: &'a ServerName,
#[ruma_api(query)]
pub origin_server_ts: MilliSecondsSinceUnixEpoch,
#[ruma_api(query)]
#[serde(rename = "type")]
pub event_type: EventType,
#[ruma_api(query)]
pub state_key: &'a str,
#[ruma_api(query)]
pub content: Raw<MemberEventContent>,
#[ruma_api(query)]
pub depth: UInt,
}
#[derive(Default)]
response: {
#[ruma_api(body)]
#[serde(with = "crate::serde::v1_pdu")]
pub empty: Empty,
}
}
#[derive(Debug)]
#[allow(clippy::exhaustive_structs)]
pub struct RequestInit<'a> {
pub room_id: &'a RoomId,
pub event_id: &'a EventId,
pub sender: &'a UserId,
pub origin: &'a ServerName,
pub origin_server_ts: MilliSecondsSinceUnixEpoch,
pub event_type: EventType,
pub state_key: &'a str,
pub content: Raw<MemberEventContent>,
pub depth: UInt,
}
impl<'a> From<RequestInit<'a>> for Request<'a> {
fn from(init: RequestInit<'a>) -> Self {
let RequestInit {
room_id,
event_id,
sender,
origin,
origin_server_ts,
event_type,
state_key,
content,
depth,
} = init;
Self {
room_id,
event_id,
sender,
origin,
origin_server_ts,
event_type,
state_key,
content,
depth,
}
}
}
impl Response {
pub fn new() -> Self {
Self { empty: Empty {} }
}
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[allow(clippy::exhaustive_structs)]
pub struct Empty {}
impl Empty {
pub fn new() -> Self {
Self {}
}
}