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        api::{request, response, Metadata},
12        metadata, OwnedUserId,
13    };
14
15    const METADATA: Metadata = metadata! {
16        method: POST,
17        rate_limited: true,
18        authentication: AccessToken,
19        history: {
20            unstable => "/_matrix/client/unstable/org.matrix.msc4260/users/:user_id/report",
21            1.14 => "/_matrix/client/v3/users/:user_id/report",
22        }
23    };
24
25    /// Request type for the `report_user` endpoint.
26    #[request(error = crate::Error)]
27    pub struct Request {
28        /// The ID of the user to report.
29        #[ruma_api(path)]
30        pub user_id: OwnedUserId,
31
32        /// The reason to report the user, may be empty.
33        pub reason: String,
34    }
35
36    /// Response type for the `report_user` endpoint.
37    #[response(error = crate::Error)]
38    #[derive(Default)]
39    pub struct Response {}
40
41    impl Request {
42        /// Creates a new `Request` with the given user ID and reason.
43        pub fn new(user_id: OwnedUserId, reason: String) -> Self {
44            Self { user_id, reason }
45        }
46    }
47
48    impl Response {
49        /// Creates an empty `Response`.
50        pub fn new() -> Self {
51            Self {}
52        }
53    }
54}