Use ruma-api-macros for the tag endpoints.
This commit is contained in:
parent
f94cb9d62a
commit
995fa6e1ae
@ -40,7 +40,7 @@ pub mod r0 {
|
||||
pub mod server;
|
||||
pub mod session;
|
||||
pub mod sync;
|
||||
// pub mod tag;
|
||||
pub mod tag;
|
||||
// pub mod typing;
|
||||
// pub mod voip;
|
||||
}
|
||||
|
205
src/r0/tag.rs
205
src/r0/tag.rs
@ -2,177 +2,98 @@
|
||||
|
||||
/// [PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-user-userid-rooms-roomid-tags-tag)
|
||||
pub mod create_tag {
|
||||
use ruma_identifiers::{UserId, RoomId};
|
||||
use ruma_api_macros::ruma_api;
|
||||
use ruma_events::tag::TagInfo;
|
||||
use ruma_identifiers::{UserId, RoomId};
|
||||
|
||||
/// Details about this API endpoint.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Endpoint;
|
||||
ruma_api! {
|
||||
metadata {
|
||||
description: "Add a new tag to a room.",
|
||||
method: Method::Put,
|
||||
name: "create_tag",
|
||||
path: "/_matrix/client/r0/user/:user_id/rooms/:room_id/tags/:tag",
|
||||
rate_limited: false,
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
/// This API endpoint's path parameters.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct PathParams {
|
||||
pub user_id: UserId,
|
||||
request {
|
||||
/// The room to tag.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: RoomId,
|
||||
pub tag: String
|
||||
/// The name of the tag to create.
|
||||
#[ruma_api(path)]
|
||||
pub tag: String,
|
||||
/// Info about the tag.
|
||||
#[ruma_api(body)]
|
||||
pub tag_info: TagInfo,
|
||||
/// The ID of the user creating the tag.
|
||||
#[ruma_api(path)]
|
||||
pub user_id: UserId,
|
||||
}
|
||||
|
||||
impl ::Endpoint for Endpoint {
|
||||
type BodyParams = TagInfo;
|
||||
type PathParams = PathParams;
|
||||
type QueryParams = ();
|
||||
type Response = ();
|
||||
|
||||
fn method() -> ::Method {
|
||||
::Method::Put
|
||||
}
|
||||
|
||||
fn request_path(params: Self::PathParams) -> String {
|
||||
format!(
|
||||
"/_matrix/client/r0/user/{}/rooms/{}/tags/{}",
|
||||
params.user_id,
|
||||
params.room_id,
|
||||
params.tag
|
||||
)
|
||||
}
|
||||
|
||||
fn router_path() -> &'static str {
|
||||
"/_matrix/client/r0/user/:user_id/rooms/:room_id/tags/:tag"
|
||||
}
|
||||
|
||||
fn name() -> &'static str {
|
||||
"create_tag"
|
||||
}
|
||||
|
||||
fn description() -> &'static str {
|
||||
"Add a new tag to a room."
|
||||
}
|
||||
|
||||
fn requires_authentication() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn rate_limited() -> bool {
|
||||
false
|
||||
}
|
||||
response {}
|
||||
}
|
||||
}
|
||||
|
||||
/// [GET /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-user-userid-rooms-roomid-tags)
|
||||
pub mod get_tags {
|
||||
use ruma_identifiers::{UserId, RoomId};
|
||||
use ruma_api_macros::ruma_api;
|
||||
use ruma_events::tag::TagEventContent;
|
||||
use ruma_identifiers::{UserId, RoomId};
|
||||
|
||||
/// Details about this API endpoint.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Endpoint;
|
||||
ruma_api! {
|
||||
metadata {
|
||||
description: "Get the tags associated with a room.",
|
||||
method: Method::Get,
|
||||
name: "get_tags",
|
||||
path: "/_matrix/client/r0/user/:user_id/rooms/:room_id/tags",
|
||||
rate_limited: false,
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
/// This API endpoint's path parameters.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct PathParams {
|
||||
request {
|
||||
/// The room from which tags will be retrieved.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: RoomId,
|
||||
/// The user whose tags will be retrieved.
|
||||
#[ruma_api(path)]
|
||||
pub user_id: UserId,
|
||||
pub room_id: RoomId
|
||||
}
|
||||
|
||||
/// This API endpoint's path parameters.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct Response {
|
||||
response {
|
||||
/// The user's tags for the room.
|
||||
pub tags: TagEventContent,
|
||||
}
|
||||
|
||||
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/user/{}/rooms/{}/tags",
|
||||
params.user_id,
|
||||
params.room_id
|
||||
)
|
||||
}
|
||||
|
||||
fn router_path() -> &'static str {
|
||||
"/_matrix/client/r0/user/:user_id/rooms/:room_id/tags"
|
||||
}
|
||||
|
||||
fn name() -> &'static str {
|
||||
"get_tags"
|
||||
}
|
||||
|
||||
fn description() -> &'static str {
|
||||
"Get the tags associated with a room."
|
||||
}
|
||||
|
||||
fn requires_authentication() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn rate_limited() -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// [DELETE /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}](https://matrix.org/docs/spec/client_server/r0.2.0.html#delete-matrix-client-r0-user-userid-rooms-roomid-tags-tag)
|
||||
pub mod delete_tag {
|
||||
use ruma_api_macros::ruma_api;
|
||||
use ruma_identifiers::{UserId, RoomId};
|
||||
|
||||
/// Details about this API endpoint.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Endpoint;
|
||||
ruma_api! {
|
||||
metadata {
|
||||
description: "Remove a tag from a room.",
|
||||
method: Method::Delete,
|
||||
name: "delete_tag",
|
||||
path: "/_matrix/client/r0/user/:user_id/rooms/:room_id/tags/:tag",
|
||||
rate_limited: false,
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
/// This API endpoint's path parameters.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct PathParams {
|
||||
pub user_id: UserId,
|
||||
request {
|
||||
/// The tagged room.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: RoomId,
|
||||
pub tag: String
|
||||
/// The name of the tag to delete.
|
||||
#[ruma_api(path)]
|
||||
pub tag: String,
|
||||
/// The user whose tag will be deleted.
|
||||
#[ruma_api(path)]
|
||||
pub user_id: UserId,
|
||||
}
|
||||
|
||||
impl ::Endpoint for Endpoint {
|
||||
type BodyParams = ();
|
||||
type PathParams = PathParams;
|
||||
type QueryParams = ();
|
||||
type Response = ();
|
||||
|
||||
fn method() -> ::Method {
|
||||
::Method::Delete
|
||||
}
|
||||
|
||||
fn request_path(params: Self::PathParams) -> String {
|
||||
format!(
|
||||
"/_matrix/client/r0/user/{}/rooms/{}/tags/{}",
|
||||
params.user_id,
|
||||
params.room_id,
|
||||
params.tag
|
||||
)
|
||||
}
|
||||
|
||||
fn router_path() -> &'static str {
|
||||
"/_matrix/client/r0/user/:user_id/rooms/:room_id/tags/:tag"
|
||||
}
|
||||
|
||||
fn name() -> &'static str {
|
||||
"delete_tag"
|
||||
}
|
||||
|
||||
fn description() -> &'static str {
|
||||
"Remove a tag from a room."
|
||||
}
|
||||
|
||||
fn requires_authentication() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn rate_limited() -> bool {
|
||||
false
|
||||
}
|
||||
response {}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user