Skip to main content

ruma_client_api/room/
report_content.rs

1//! `POST /_matrix/client/*/rooms/{roomId}/report/{eventId}`
2//!
3//! Report content as inappropriate.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#post_matrixclientv3roomsroomidreporteventid
9
10    use ruma_common::{
11        OwnedEventId, OwnedRoomId,
12        api::{auth_scheme::AccessToken, request, response},
13        metadata,
14    };
15
16    metadata! {
17        method: POST,
18        rate_limited: false,
19        authentication: AccessToken,
20        history: {
21            1.0 => "/_matrix/client/r0/rooms/{room_id}/report/{event_id}",
22            1.1 => "/_matrix/client/v3/rooms/{room_id}/report/{event_id}",
23        }
24    }
25
26    /// Request type for the `report_content` endpoint.
27    #[request(error = crate::Error)]
28    pub struct Request {
29        /// Room in which the event to be reported is located.
30        #[ruma_api(path)]
31        pub room_id: OwnedRoomId,
32
33        /// Event to report.
34        #[ruma_api(path)]
35        pub event_id: OwnedEventId,
36
37        /// Reason to report content.
38        #[serde(skip_serializing_if = "Option::is_none")]
39        pub reason: Option<String>,
40    }
41
42    /// Response type for the `report_content` 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 ad event ID.
49        pub fn new(room_id: OwnedRoomId, event_id: OwnedEventId) -> Self {
50            Self { room_id, event_id, reason: None }
51        }
52    }
53
54    impl Response {
55        /// Creates an empty `Response`.
56        pub fn new() -> Self {
57            Self {}
58        }
59    }
60}