Skip to main content

ruma_client_api/profile/
delete_profile_field.rs

1//! `DELETE /_matrix/client/*/profile/{userId}/{key_name}`
2//!
3//! Delete a field on the profile of the user.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/v1.18/client-server-api/#delete_matrixclientv3profileuseridkeyname
9
10    use ruma_common::{
11        OwnedUserId,
12        api::{auth_scheme::AccessToken, request, response},
13        metadata,
14        profile::ProfileFieldName,
15    };
16
17    #[cfg(feature = "unstable-msc4466")]
18    use crate::profile::PropagateTo;
19
20    metadata! {
21        method: DELETE,
22        rate_limited: true,
23        authentication: AccessToken,
24        history: {
25            unstable("uk.tcpip.msc4133") => "/_matrix/client/unstable/uk.tcpip.msc4133/profile/{user_id}/{field}",
26            1.16 => "/_matrix/client/v3/profile/{user_id}/{field}",
27        }
28    }
29
30    /// Request type for the `delete_profile_field` endpoint.
31    #[request]
32    pub struct Request {
33        /// The user whose profile will be updated.
34        #[ruma_api(path)]
35        pub user_id: OwnedUserId,
36
37        /// The profile field to delete.
38        #[ruma_api(path)]
39        pub field: ProfileFieldName,
40
41        /// The propagation mode to use for this profile update.
42        #[cfg(feature = "unstable-msc4466")]
43        #[ruma_api(query)]
44        #[serde(rename = "computer.gingershaped.msc4466.propagate_to")]
45        #[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
46        pub propagate_to: PropagateTo,
47    }
48
49    impl Request {
50        /// Creates a new `Request` with the given user ID and field.
51        pub fn new(user_id: OwnedUserId, field: ProfileFieldName) -> Self {
52            Self {
53                user_id,
54                field,
55                #[cfg(feature = "unstable-msc4466")]
56                propagate_to: PropagateTo::default(),
57            }
58        }
59    }
60
61    /// Response type for the `delete_profile_field` endpoint.
62    #[response]
63    #[derive(Default)]
64    pub struct Response {}
65
66    impl Response {
67        /// Creates an empty `Response`.
68        pub fn new() -> Self {
69            Self {}
70        }
71    }
72}