ruma_client_api/room/report_room.rs
1//! `POST /_matrix/client/*/rooms/{roomId}/report`
2//!
3//! Report a room as inappropriate.
4
5pub mod v3 {
6 //! `/v3/` ([spec])
7 //!
8 //! [spec]: https://spec.matrix.org/latest/client-server-api/#post_matrixclientv3roomsroomidreport
9
10 use ruma_common::{
11 OwnedRoomId,
12 api::{auth_scheme::AccessToken, request, response},
13 metadata,
14 };
15
16 metadata! {
17 method: POST,
18 rate_limited: true,
19 authentication: AccessToken,
20 history: {
21 unstable => "/_matrix/client/unstable/org.matrix.msc4151/rooms/{room_id}/report",
22 1.13 => "/_matrix/client/v3/rooms/{room_id}/report",
23 }
24 }
25
26 /// Request type for the `report_room` endpoint.
27 #[request(error = crate::Error)]
28 pub struct Request {
29 /// The ID of the room to report.
30 #[ruma_api(path)]
31 pub room_id: OwnedRoomId,
32
33 /// The reason to report the room, may be empty.
34 // We deserialize a missing field as an empty string for backwards compatibility. The field
35 // was initially specified as optional in Matrix 1.13 and then clarified as being required
36 // in Matrix 1.14 to align with its initial definition in MSC4151.
37 // See: https://github.com/matrix-org/matrix-spec/pull/2093#discussion_r1993171166
38 #[serde(default)]
39 pub reason: String,
40 }
41
42 /// Response type for the `report_room` endpoint.
43 #[response(error = crate::Error)]
44 #[derive(Default)]
45 pub struct Response {}
46
47 impl Request {
48 /// Creates a new `Request` with the given room ID and reason.
49 pub fn new(room_id: OwnedRoomId, reason: String) -> Self {
50 Self { room_id, reason }
51 }
52 }
53
54 impl Response {
55 /// Creates an empty `Response`.
56 pub fn new() -> Self {
57 Self {}
58 }
59 }
60}