Skip to main content

ruma_client_api/
profile.rs

1//! Endpoints for user profiles.
2
3#[cfg(feature = "client")]
4use ruma_common::{
5    api::{
6        MatrixVersion,
7        path_builder::{StablePathSelector, VersionHistory},
8    },
9    profile::ProfileFieldName,
10};
11
12pub mod delete_profile_field;
13pub mod get_avatar_url;
14pub mod get_display_name;
15pub mod get_profile;
16pub mod get_profile_field;
17#[cfg(feature = "client")]
18mod profile_field_serde;
19pub mod set_avatar_url;
20pub mod set_display_name;
21pub mod set_profile_field;
22mod static_profile_field;
23
24pub use self::static_profile_field::*;
25
26/// Endpoint version history valid only for profile fields that didn't exist before Matrix 1.16.
27#[cfg(feature = "client")]
28const EXTENDED_PROFILE_FIELD_HISTORY: VersionHistory = VersionHistory::new(
29    &[(
30        Some("uk.tcpip.msc4133"),
31        "/_matrix/client/unstable/uk.tcpip.msc4133/profile/{user_id}/{field}",
32    )],
33    &[(
34        StablePathSelector::Version(MatrixVersion::V1_16),
35        "/_matrix/client/v3/profile/{user_id}/{field}",
36    )],
37    None,
38    None,
39);
40
41/// Whether the given field name existed already before custom fields were officially supported in
42/// profiles.
43#[cfg(feature = "client")]
44fn field_existed_before_extended_profiles(field_name: &ProfileFieldName) -> bool {
45    matches!(field_name, ProfileFieldName::AvatarUrl | ProfileFieldName::DisplayName)
46}