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 js_int::Int;
11    use ruma_common::{
12        OwnedEventId, OwnedRoomId,
13        api::{auth_scheme::AccessToken, request, response},
14        metadata,
15    };
16
17    metadata! {
18        method: POST,
19        rate_limited: false,
20        authentication: AccessToken,
21        history: {
22            1.0 => "/_matrix/client/r0/rooms/{room_id}/report/{event_id}",
23            1.1 => "/_matrix/client/v3/rooms/{room_id}/report/{event_id}",
24        }
25    }
26
27    /// Request type for the `report_content` endpoint.
28    #[request(error = crate::Error)]
29    pub struct Request {
30        /// Room in which the event to be reported is located.
31        #[ruma_api(path)]
32        pub room_id: OwnedRoomId,
33
34        /// Event to report.
35        #[ruma_api(path)]
36        pub event_id: OwnedEventId,
37
38        /// Integer between -100 and 0 rating offensivness.
39        #[serde(skip_serializing_if = "Option::is_none")]
40        pub score: Option<Int>,
41
42        /// Reason to report content.
43        #[serde(skip_serializing_if = "Option::is_none")]
44        pub reason: Option<String>,
45    }
46
47    /// Response type for the `report_content` endpoint.
48    #[response(error = crate::Error)]
49    #[derive(Default)]
50    pub struct Response {}
51
52    impl Request {
53        /// Creates a new `Request` with the given room ID, event ID, score and reason.
54        pub fn new(
55            room_id: OwnedRoomId,
56            event_id: OwnedEventId,
57            score: Option<Int>,
58            reason: Option<String>,
59        ) -> Self {
60            Self { room_id, event_id, score, reason }
61        }
62    }
63
64    impl Response {
65        /// Creates an empty `Response`.
66        pub fn new() -> Self {
67            Self {}
68        }
69    }
70}