Add profile information query endpoint

This commit is contained in:
skim 2020-06-30 14:13:43 -07:00
parent 41b8bd77f5
commit 3a515124ec
No known key found for this signature in database
GPG Key ID: C34FAB15A47E38FA
4 changed files with 57 additions and 2 deletions

View File

@ -18,7 +18,10 @@ Improvements:
create_join_event::v1,
create_join_event_template::v1
},
query::get_room_information::v1,
query::{
get_profile_information::v1,
get_room_information::v1,
},
transactions::send_transaction_message::v1,
version::get_server_version::v1
```
@ -27,4 +30,4 @@ Improvements:
Improvements:
* Provide `RoomV3Pdu` type for room versions 3 and above
* Provide `RoomV3Pdu` type for room versions 3 and above

View File

@ -1,3 +1,4 @@
//! Endpoints to retrieve information from a homeserver about a resource.
pub mod get_profile_information;
pub mod get_room_information;

View File

@ -0,0 +1,2 @@
//! Endpoint to query profile information with a user id and optional field.
pub mod v1;

View File

@ -0,0 +1,49 @@
//! [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::UserId;
use serde::{Deserialize, Serialize};
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,
requires_authentication: true,
}
request: {
/// User ID to query.
#[ruma_api(query)]
pub user_id: UserId,
/// Profile field to query.
#[serde(skip_serializing_if = "Option::is_none")]
#[ruma_api(query)]
pub field: Option<ProfileField>,
}
response: {
/// Display name of the user.
#[serde(skip_serializing_if = "Option::is_none")]
pub displayname: Option<String>,
/// Avatar URL for the user's avatar.
#[serde(skip_serializing_if = "Option::is_none")]
pub avatar_url: Option<String>,
}
}
/// Profile fields to specify in query.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum ProfileField {
/// Display name of the user.
#[serde(rename = "displayname")]
DisplayName,
/// Avatar URL for the user's avatar.
#[serde(rename = "avatar_url")]
AvatarUrl,
}