* Add blurhash to profile and avatar endpoints. * Add `blurhash` fields to `GET /_matrix/federation/v1/query/profile` and `m.room.member`. * Add `generate_blurhash` field to `PUT /_matrix/media/r0/upload`
85 lines
2.5 KiB
Rust
85 lines
2.5 KiB
Rust
//! [GET /_matrix/federation/v1/query/profile](https://matrix.org/docs/spec/server_server/r0.1.4#get-matrix-federation-v1-query-profile)
|
|
|
|
use ruma_api::ruma_api;
|
|
use ruma_identifiers::{MxcUri, UserId};
|
|
use ruma_serde::StringEnum;
|
|
|
|
ruma_api! {
|
|
metadata: {
|
|
description: "Get profile information, such as a display name or avatar, for a given user.",
|
|
name: "get_profile_information",
|
|
method: GET,
|
|
path: "/_matrix/federation/v1/query/profile",
|
|
rate_limited: false,
|
|
authentication: ServerSignatures,
|
|
}
|
|
|
|
request: {
|
|
/// User ID to query.
|
|
#[ruma_api(query)]
|
|
pub user_id: &'a UserId,
|
|
|
|
/// Profile field to query.
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
#[ruma_api(query)]
|
|
pub field: Option<&'a ProfileField>,
|
|
}
|
|
|
|
#[derive(Default)]
|
|
response: {
|
|
/// Display name of the user.
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub displayname: Option<String>,
|
|
|
|
/// Avatar URL for the user's avatar.
|
|
///
|
|
/// If you activate the `compat` feature, this field being an empty string in JSON will give
|
|
/// you `None` here.
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
#[cfg_attr(
|
|
feature = "compat",
|
|
serde(default, deserialize_with = "ruma_serde::empty_string_as_none")
|
|
)]
|
|
pub avatar_url: Option<MxcUri>,
|
|
|
|
/// The [BlurHash](https://blurha.sh) for the avatar pointed to by `avatar_url`.
|
|
///
|
|
/// This uses the unstable prefix in
|
|
/// [MSC2448](https://github.com/matrix-org/matrix-doc/pull/2448).
|
|
#[cfg(feature = "unstable-pre-spec")]
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))]
|
|
#[serde(rename = "xyz.amorgan.blurhash")]
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub blurhash: Option<String>,
|
|
}
|
|
}
|
|
|
|
impl<'a> Request<'a> {
|
|
/// Creates a new `Request` with the given user id.
|
|
pub fn new(user_id: &'a UserId) -> Self {
|
|
Self { user_id, field: None }
|
|
}
|
|
}
|
|
|
|
impl Response {
|
|
/// Creates an empty `Response`.
|
|
pub fn new() -> Self {
|
|
Default::default()
|
|
}
|
|
}
|
|
|
|
/// Profile fields to specify in query.
|
|
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
|
pub enum ProfileField {
|
|
/// Display name of the user.
|
|
#[ruma_enum(rename = "displayname")]
|
|
DisplayName,
|
|
|
|
/// Avatar URL for the user's avatar.
|
|
#[ruma_enum(rename = "avatar_url")]
|
|
AvatarUrl,
|
|
|
|
#[doc(hidden)]
|
|
_Custom(String),
|
|
}
|