Use ruma-api-macros for the profile endpoints.
This commit is contained in:
parent
a5427a5daf
commit
beacb5f268
@ -30,7 +30,7 @@ pub mod r0 {
|
|||||||
pub mod media;
|
pub mod media;
|
||||||
pub mod membership;
|
pub mod membership;
|
||||||
pub mod presence;
|
pub mod presence;
|
||||||
// pub mod profile;
|
pub mod profile;
|
||||||
// pub mod push;
|
// pub mod push;
|
||||||
// pub mod receipt;
|
// pub mod receipt;
|
||||||
// pub mod redact;
|
// pub mod redact;
|
||||||
|
@ -2,303 +2,145 @@
|
|||||||
|
|
||||||
/// [GET /_matrix/client/r0/profile/{userId}/displayname](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-profile-userid-displayname)
|
/// [GET /_matrix/client/r0/profile/{userId}/displayname](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-profile-userid-displayname)
|
||||||
pub mod get_display_name {
|
pub mod get_display_name {
|
||||||
|
use ruma_api_macros::ruma_api;
|
||||||
use ruma_identifiers::UserId;
|
use ruma_identifiers::UserId;
|
||||||
|
|
||||||
/// This API endpoint's path parameters.
|
ruma_api! {
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
metadata {
|
||||||
pub struct PathParams {
|
description: "Get the display name of a user.",
|
||||||
|
method: Method::Get,
|
||||||
|
name: "get_display_name",
|
||||||
|
path: "/_matrix/client/r0/profile/:user_id/displayname",
|
||||||
|
rate_limited: false,
|
||||||
|
requires_authentication: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
request {
|
||||||
|
/// The user whose display name will be retrieved.
|
||||||
|
#[ruma_api(path)]
|
||||||
pub user_id: UserId
|
pub user_id: UserId
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This API endpoint's body parameters.
|
response {
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
/// The user's display name, if set.
|
||||||
pub struct Response {
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub displayname: Option<String>
|
pub displayname: Option<String>
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Details about this API endpoint.
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
|
||||||
pub struct Endpoint;
|
|
||||||
|
|
||||||
impl ::Endpoint for Endpoint {
|
|
||||||
type BodyParams = ();
|
|
||||||
type PathParams = PathParams;
|
|
||||||
type QueryParams = ();
|
|
||||||
type Response = Response;
|
|
||||||
|
|
||||||
fn method() -> ::Method {
|
|
||||||
::Method::Get
|
|
||||||
}
|
|
||||||
|
|
||||||
fn request_path(params: Self::PathParams) -> String {
|
|
||||||
format!(
|
|
||||||
"/_matrix/client/r0/profile/{}/displayname",
|
|
||||||
params.user_id
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn router_path() -> &'static str {
|
|
||||||
"/_matrix/client/r0/profile/:user_id/displayname"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name() -> &'static str {
|
|
||||||
"get_display_name"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn description() -> &'static str {
|
|
||||||
"Get the display name of a user."
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requires_authentication() -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rate_limited() -> bool {
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// [PUT /_matrix/client/r0/profile/{userId}/displayname](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-profile-userid-displayname)
|
/// [PUT /_matrix/client/r0/profile/{userId}/displayname](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-profile-userid-displayname)
|
||||||
pub mod set_display_name {
|
pub mod set_display_name {
|
||||||
|
use ruma_api_macros::ruma_api;
|
||||||
use ruma_identifiers::UserId;
|
use ruma_identifiers::UserId;
|
||||||
|
|
||||||
/// This API endpoint's path parameters.
|
ruma_api! {
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
metadata {
|
||||||
pub struct PathParams {
|
description: "Set the display name of the user.",
|
||||||
pub user_id: UserId
|
method: Method::Put,
|
||||||
|
name: "set_display_name",
|
||||||
|
path: "/_matrix/client/r0/profile/:user_id/displayname",
|
||||||
|
rate_limited: true,
|
||||||
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This API endpoint's body parameters.
|
request {
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
/// The new display name for the user.
|
||||||
pub struct BodyParams {
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub displayname: Option<String>
|
pub displayname: Option<String>,
|
||||||
|
/// The user whose display name will be set.
|
||||||
|
#[ruma_api(path)]
|
||||||
|
pub user_id: UserId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Details about this API endpoint.
|
response {}
|
||||||
#[derive(Clone, Copy, Debug)]
|
|
||||||
pub struct Endpoint;
|
|
||||||
|
|
||||||
impl ::Endpoint for Endpoint {
|
|
||||||
type BodyParams = BodyParams;
|
|
||||||
type PathParams = PathParams;
|
|
||||||
type QueryParams = ();
|
|
||||||
type Response = ();
|
|
||||||
|
|
||||||
fn method() -> ::Method {
|
|
||||||
::Method::Put
|
|
||||||
}
|
|
||||||
|
|
||||||
fn request_path(params: Self::PathParams) -> String {
|
|
||||||
format!(
|
|
||||||
"/_matrix/client/r0/profile/{}/displayname",
|
|
||||||
params.user_id
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn router_path() -> &'static str {
|
|
||||||
"/_matrix/client/r0/profile/:user_id/displayname"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name() -> &'static str {
|
|
||||||
"set_display_name"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn description() -> &'static str {
|
|
||||||
"Set the display name of the user."
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requires_authentication() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rate_limited() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [GET /_matrix/client/r0/profile/{userId}/avatar_url](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-profile-userid-avatar-url)
|
/// [GET /_matrix/client/r0/profile/{userId}/avatar_url](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-profile-userid-avatar-url)
|
||||||
pub mod get_avatar_url {
|
pub mod get_avatar_url {
|
||||||
|
use ruma_api_macros::ruma_api;
|
||||||
use ruma_identifiers::UserId;
|
use ruma_identifiers::UserId;
|
||||||
|
|
||||||
/// This API endpoint's path parameters.
|
ruma_api! {
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
metadata {
|
||||||
pub struct PathParams {
|
description: "Get the avatar URL of a user.",
|
||||||
|
method: Method::Get,
|
||||||
|
name: "get_avatar_url",
|
||||||
|
path: "/_matrix/client/r0/profile/:user_id/avatar_url",
|
||||||
|
rate_limited: false,
|
||||||
|
requires_authentication: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
request {
|
||||||
|
/// The user whose avatar URL will be retrieved.
|
||||||
|
#[ruma_api(path)]
|
||||||
pub user_id: UserId
|
pub user_id: UserId
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This API endpoint's body parameters.
|
response {
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
/// The user's avatar URL, if set.
|
||||||
pub struct Response {
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub avatar_url: Option<String>
|
pub avatar_url: Option<String>
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Details about this API endpoint.
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
|
||||||
pub struct Endpoint;
|
|
||||||
|
|
||||||
impl ::Endpoint for Endpoint {
|
|
||||||
type BodyParams = ();
|
|
||||||
type PathParams = PathParams;
|
|
||||||
type QueryParams = ();
|
|
||||||
type Response = Response;
|
|
||||||
|
|
||||||
fn method() -> ::Method {
|
|
||||||
::Method::Get
|
|
||||||
}
|
|
||||||
|
|
||||||
fn request_path(params: Self::PathParams) -> String {
|
|
||||||
format!(
|
|
||||||
"/_matrix/client/r0/profile/{}/avatar_url",
|
|
||||||
params.user_id
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn router_path() -> &'static str {
|
|
||||||
"/_matrix/client/r0/profile/:user_id/avatar_url"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name() -> &'static str {
|
|
||||||
"get_avatar_url"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn description() -> &'static str {
|
|
||||||
"Get the avatar URL of a user."
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requires_authentication() -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rate_limited() -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [PUT /_matrix/client/r0/profile/{userId}/avatar_url](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-profile-userid-avatar-url)
|
/// [PUT /_matrix/client/r0/profile/{userId}/avatar_url](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-profile-userid-avatar-url)
|
||||||
pub mod set_avatar_url {
|
pub mod set_avatar_url {
|
||||||
|
use ruma_api_macros::ruma_api;
|
||||||
use ruma_identifiers::UserId;
|
use ruma_identifiers::UserId;
|
||||||
|
|
||||||
/// This API endpoint's path parameters.
|
ruma_api! {
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
metadata {
|
||||||
pub struct PathParams {
|
description: "Set the avatar URL of the user.",
|
||||||
|
method: Method::Put,
|
||||||
|
name: "set_avatar_url",
|
||||||
|
path: "/_matrix/client/r0/profile/:user_id/avatar_url",
|
||||||
|
rate_limited: true,
|
||||||
|
requires_authentication: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
request {
|
||||||
|
/// The new avatar URL for the user.
|
||||||
|
pub avatar_url: String,
|
||||||
|
/// The user whose avatar URL will be set.
|
||||||
|
#[ruma_api(path)]
|
||||||
pub user_id: UserId
|
pub user_id: UserId
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This API endpoint's body parameters.
|
response {}
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
||||||
pub struct BodyParams {
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub avatar_url: Option<String>
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Details about this API endpoint.
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
|
||||||
pub struct Endpoint;
|
|
||||||
|
|
||||||
impl ::Endpoint for Endpoint {
|
|
||||||
type BodyParams = BodyParams;
|
|
||||||
type PathParams = PathParams;
|
|
||||||
type QueryParams = ();
|
|
||||||
type Response = ();
|
|
||||||
|
|
||||||
fn method() -> ::Method {
|
|
||||||
::Method::Put
|
|
||||||
}
|
|
||||||
|
|
||||||
fn request_path(params: Self::PathParams) -> String {
|
|
||||||
format!(
|
|
||||||
"/_matrix/client/r0/profile/{}/avatar_url",
|
|
||||||
params.user_id
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn router_path() -> &'static str {
|
|
||||||
"/_matrix/client/r0/profile/:user_id/avatar_url"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name() -> &'static str {
|
|
||||||
"set_avatar_url"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn description() -> &'static str {
|
|
||||||
"Set the avatar URL of the user."
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requires_authentication() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rate_limited() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [GET /_matrix/client/r0/profile/{userId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-profile-userid)
|
/// [GET /_matrix/client/r0/profile/{userId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-profile-userid)
|
||||||
pub mod get_profile {
|
pub mod get_profile {
|
||||||
|
use ruma_api_macros::ruma_api;
|
||||||
use ruma_identifiers::UserId;
|
use ruma_identifiers::UserId;
|
||||||
|
|
||||||
/// This API endpoint's path parameters.
|
ruma_api! {
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
metadata {
|
||||||
pub struct PathParams {
|
description: "Get all profile information of an user.",
|
||||||
|
method: Method::Get,
|
||||||
|
name: "get_profile",
|
||||||
|
path: "/_matrix/client/r0/profile/:user_id",
|
||||||
|
rate_limited: false,
|
||||||
|
requires_authentication: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
request {
|
||||||
|
/// The user whose profile will be retrieved.
|
||||||
|
#[ruma_api(path)]
|
||||||
pub user_id: UserId
|
pub user_id: UserId
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This API endpoint's body parameters.
|
response {
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
/// The user's avatar URL, if set.
|
||||||
pub struct Response {
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub avatar_url: Option<String>,
|
pub avatar_url: Option<String>,
|
||||||
|
/// The user's display name, if set.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub displayname: Option<String>
|
pub displayname: Option<String>
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Details about this API endpoint.
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
|
||||||
pub struct Endpoint;
|
|
||||||
|
|
||||||
impl ::Endpoint for Endpoint {
|
|
||||||
type BodyParams = ();
|
|
||||||
type PathParams = PathParams;
|
|
||||||
type QueryParams = ();
|
|
||||||
type Response = Response;
|
|
||||||
|
|
||||||
fn method() -> ::Method {
|
|
||||||
::Method::Get
|
|
||||||
}
|
|
||||||
|
|
||||||
fn request_path(params: Self::PathParams) -> String {
|
|
||||||
format!(
|
|
||||||
"/_matrix/client/r0/profile/{}",
|
|
||||||
params.user_id
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn router_path() -> &'static str {
|
|
||||||
"/_matrix/client/r0/profile/:user_id"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name() -> &'static str {
|
|
||||||
"get_profile"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn description() -> &'static str {
|
|
||||||
"Get all profile information of an user."
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requires_authentication() -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rate_limited() -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user