partial impl GET/PUT for MSC4133 and MSC4175
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
c8a2d06e24
commit
bf93f9caa6
@ -3,5 +3,7 @@
|
|||||||
pub mod get_avatar_url;
|
pub mod get_avatar_url;
|
||||||
pub mod get_display_name;
|
pub mod get_display_name;
|
||||||
pub mod get_profile;
|
pub mod get_profile;
|
||||||
|
pub mod get_timezone_key;
|
||||||
pub mod set_avatar_url;
|
pub mod set_avatar_url;
|
||||||
pub mod set_display_name;
|
pub mod set_display_name;
|
||||||
|
pub mod set_timezone_key;
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
//! `GET /_matrix/client/*/profile/{userId}`
|
//! `GET /_matrix/client/*/profile/{userId}`
|
||||||
//!
|
//!
|
||||||
//! Get all profile information of an user.
|
//! Get all profile information of an user.
|
||||||
|
//!
|
||||||
|
//! TODO: implement the "generic-ness" of MSC4133
|
||||||
|
|
||||||
pub mod v3 {
|
pub mod v3 {
|
||||||
//! `/v3/` ([spec])
|
//! `/v3/` ([spec])
|
||||||
//!
|
//!
|
||||||
//! [spec]: https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3profileuserid
|
//! [spec]: https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3profileuserid
|
||||||
|
//!
|
||||||
|
//! also see: `msc4133` ([MSC])
|
||||||
|
//!
|
||||||
|
//! [MSC]: https://github.com/tcpipuk/matrix-spec-proposals/blob/main/proposals/4133-extended-profiles.md
|
||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
@ -17,6 +23,7 @@ pub mod v3 {
|
|||||||
rate_limited: false,
|
rate_limited: false,
|
||||||
authentication: None,
|
authentication: None,
|
||||||
history: {
|
history: {
|
||||||
|
unstable => "/_matrix/client/unstable/uk.tcpip.msc4133/profile/:user_id",
|
||||||
1.0 => "/_matrix/client/r0/profile/:user_id",
|
1.0 => "/_matrix/client/r0/profile/:user_id",
|
||||||
1.1 => "/_matrix/client/v3/profile/:user_id",
|
1.1 => "/_matrix/client/v3/profile/:user_id",
|
||||||
}
|
}
|
||||||
@ -56,6 +63,14 @@ pub mod v3 {
|
|||||||
#[cfg(feature = "unstable-msc2448")]
|
#[cfg(feature = "unstable-msc2448")]
|
||||||
#[serde(rename = "xyz.amorgan.blurhash", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "xyz.amorgan.blurhash", skip_serializing_if = "Option::is_none")]
|
||||||
pub blurhash: Option<String>,
|
pub blurhash: Option<String>,
|
||||||
|
|
||||||
|
/// [MSC4175][msc]: `m.tz` field for specifying a timezone the user is in
|
||||||
|
///
|
||||||
|
/// [msc]: https://github.com/matrix-org/matrix-spec-proposals/blob/clokep/profile-tz/proposals/4175-profile-field-time-zone.md
|
||||||
|
///
|
||||||
|
/// TODO: strong type this to be a valid IANA timezone?
|
||||||
|
#[serde(rename = "us.cloke.msc4175.tz", skip_serializing_if = "Option::is_none")]
|
||||||
|
pub tz: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Request {
|
impl Request {
|
||||||
@ -66,13 +81,14 @@ pub mod v3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Response {
|
impl Response {
|
||||||
/// Creates a new `Response` with the given avatar URL and display name.
|
/// Creates a new `Response` with the given avatar URL, display name, and timezone.
|
||||||
pub fn new(avatar_url: Option<OwnedMxcUri>, displayname: Option<String>) -> Self {
|
pub fn new(avatar_url: Option<OwnedMxcUri>, displayname: Option<String>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
avatar_url,
|
avatar_url,
|
||||||
displayname,
|
displayname,
|
||||||
#[cfg(feature = "unstable-msc2448")]
|
#[cfg(feature = "unstable-msc2448")]
|
||||||
blurhash: None,
|
blurhash: None,
|
||||||
|
tz: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
55
crates/ruma-client-api/src/profile/get_timezone_key.rs
Normal file
55
crates/ruma-client-api/src/profile/get_timezone_key.rs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
//! `GET /_matrix/client/*/profile/{userId}/m.tz`
|
||||||
|
//!
|
||||||
|
//! Get the timezone key of a user.
|
||||||
|
|
||||||
|
pub mod unstable {
|
||||||
|
use ruma_common::{
|
||||||
|
api::{request, response, Metadata},
|
||||||
|
metadata, OwnedUserId,
|
||||||
|
};
|
||||||
|
|
||||||
|
const METADATA: Metadata = metadata! {
|
||||||
|
method: GET,
|
||||||
|
rate_limited: false,
|
||||||
|
authentication: None,
|
||||||
|
history: {
|
||||||
|
unstable => "/_matrix/client/unstable/uk.tcpip.msc4133/profile/:user_id/us.cloke.msc4175.tz",
|
||||||
|
// 1.12 => "/_matrix/client/v3/profile/:user_id/m.tz",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Request type for the `get_timezone` endpoint.
|
||||||
|
#[request(error = crate::Error)]
|
||||||
|
pub struct Request {
|
||||||
|
/// The user whose timezone will be retrieved.
|
||||||
|
#[ruma_api(path)]
|
||||||
|
pub user_id: OwnedUserId,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Response type for the `get_timezone` endpoint.
|
||||||
|
#[response(error = crate::Error)]
|
||||||
|
#[derive(Default)]
|
||||||
|
pub struct Response {
|
||||||
|
/// [MSC4175][msc]: `m.tz` field for specifying a timezone the user is in
|
||||||
|
///
|
||||||
|
/// [msc]: https://github.com/matrix-org/matrix-spec-proposals/blob/clokep/profile-tz/proposals/4175-profile-field-time-zone.md
|
||||||
|
///
|
||||||
|
/// TODO: strong type this to be a valid IANA timezone?
|
||||||
|
#[serde(rename = "us.cloke.msc4175.tz", skip_serializing_if = "Option::is_none")]
|
||||||
|
pub tz: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Request {
|
||||||
|
/// Creates a new `Request` with the given user ID.
|
||||||
|
pub fn new(user_id: OwnedUserId) -> Self {
|
||||||
|
Self { user_id }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given timezone.
|
||||||
|
pub fn new(tz: Option<String>) -> Self {
|
||||||
|
Self { tz }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
58
crates/ruma-client-api/src/profile/set_timezone_key.rs
Normal file
58
crates/ruma-client-api/src/profile/set_timezone_key.rs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
//! `PUT /_matrix/client/*/profile/{userId}/m.tz`
|
||||||
|
//!
|
||||||
|
//! Set the timezone key of the user.
|
||||||
|
|
||||||
|
pub mod unstable {
|
||||||
|
use ruma_common::{
|
||||||
|
api::{request, response, Metadata},
|
||||||
|
metadata, OwnedUserId,
|
||||||
|
};
|
||||||
|
|
||||||
|
const METADATA: Metadata = metadata! {
|
||||||
|
method: PUT,
|
||||||
|
rate_limited: true,
|
||||||
|
authentication: AccessToken,
|
||||||
|
history: {
|
||||||
|
unstable => "/_matrix/client/unstable/uk.tcpip.msc4133/profile/:user_id/us.cloke.msc4175.tz",
|
||||||
|
// 1.12 => "/_matrix/client/v3/profile/:user_id/m.tz",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Request type for the `set_timezone_key` endpoint.
|
||||||
|
#[request(error = crate::Error)]
|
||||||
|
pub struct Request {
|
||||||
|
/// The user whose timezone will be set.
|
||||||
|
#[ruma_api(path)]
|
||||||
|
pub user_id: OwnedUserId,
|
||||||
|
|
||||||
|
/// [MSC4175][msc]: `m.tz` field for specifying a timezone the user is in
|
||||||
|
///
|
||||||
|
/// [msc]: https://github.com/matrix-org/matrix-spec-proposals/blob/clokep/profile-tz/proposals/4175-profile-field-time-zone.md
|
||||||
|
///
|
||||||
|
/// TODO: strong type this to be a valid IANA timezone?
|
||||||
|
#[serde(rename = "us.cloke.msc4175.tz", skip_serializing_if = "Option::is_none")]
|
||||||
|
pub tz: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Response type for the `set_timezone_key` endpoint.
|
||||||
|
#[response(error = crate::Error)]
|
||||||
|
#[derive(Default)]
|
||||||
|
pub struct Response {}
|
||||||
|
|
||||||
|
impl Request {
|
||||||
|
/// Creates a new `Request` with the given user ID and timezone.
|
||||||
|
pub fn new(user_id: OwnedUserId, tz: Option<String>) -> Self {
|
||||||
|
Self {
|
||||||
|
user_id,
|
||||||
|
tz,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates an empty `Response`.
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user