ruma_client_api/reporting/
report_user.rs

1//! `POST /_matrix/client/*/users/{userId}/report`
2//!
3//! Report a user as inappropriate.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#post_matrixclientv3usersuseridreport
9
10    use ruma_common::{
11        OwnedUserId,
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.msc4260/users/{user_id}/report",
22            1.14 => "/_matrix/client/v3/users/{user_id}/report",
23        }
24    }
25
26    /// Request type for the `report_user` endpoint.
27    #[request(error = crate::Error)]
28    pub struct Request {
29        /// The ID of the user to report.
30        #[ruma_api(path)]
31        pub user_id: OwnedUserId,
32
33        /// The reason to report the user, may be empty.
34        pub reason: String,
35    }
36
37    /// Response type for the `report_user` endpoint.
38    #[response(error = crate::Error)]
39    #[derive(Default)]
40    pub struct Response {}
41
42    impl Request {
43        /// Creates a new `Request` with the given user ID and reason.
44        pub fn new(user_id: OwnedUserId, reason: String) -> Self {
45            Self { user_id, reason }
46        }
47    }
48
49    impl Response {
50        /// Creates an empty `Response`.
51        pub fn new() -> Self {
52            Self {}
53        }
54    }
55}