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 server;
|
||||||
pub mod session;
|
pub mod session;
|
||||||
pub mod sync;
|
pub mod sync;
|
||||||
// pub mod tag;
|
pub mod tag;
|
||||||
// pub mod typing;
|
// pub mod typing;
|
||||||
// pub mod voip;
|
// 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)
|
/// [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 {
|
pub mod create_tag {
|
||||||
use ruma_identifiers::{UserId, RoomId};
|
use ruma_api_macros::ruma_api;
|
||||||
use ruma_events::tag::TagInfo;
|
use ruma_events::tag::TagInfo;
|
||||||
|
use ruma_identifiers::{UserId, RoomId};
|
||||||
|
|
||||||
/// Details about this API endpoint.
|
ruma_api! {
|
||||||
#[derive(Clone, Copy, Debug)]
|
metadata {
|
||||||
pub struct Endpoint;
|
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.
|
request {
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
/// The room to tag.
|
||||||
pub struct PathParams {
|
#[ruma_api(path)]
|
||||||
pub user_id: UserId,
|
|
||||||
pub room_id: RoomId,
|
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 {
|
response {}
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [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)
|
/// [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 {
|
pub mod get_tags {
|
||||||
use ruma_identifiers::{UserId, RoomId};
|
use ruma_api_macros::ruma_api;
|
||||||
use ruma_events::tag::TagEventContent;
|
use ruma_events::tag::TagEventContent;
|
||||||
|
use ruma_identifiers::{UserId, RoomId};
|
||||||
|
|
||||||
/// Details about this API endpoint.
|
ruma_api! {
|
||||||
#[derive(Clone, Copy, Debug)]
|
metadata {
|
||||||
pub struct Endpoint;
|
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.
|
request {
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
/// The room from which tags will be retrieved.
|
||||||
pub struct PathParams {
|
#[ruma_api(path)]
|
||||||
|
pub room_id: RoomId,
|
||||||
|
/// The user whose tags will be retrieved.
|
||||||
|
#[ruma_api(path)]
|
||||||
pub user_id: UserId,
|
pub user_id: UserId,
|
||||||
pub room_id: RoomId
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This API endpoint's path parameters.
|
response {
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
/// The user's tags for the room.
|
||||||
pub struct Response {
|
|
||||||
pub tags: TagEventContent,
|
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)
|
/// [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 {
|
pub mod delete_tag {
|
||||||
|
use ruma_api_macros::ruma_api;
|
||||||
use ruma_identifiers::{UserId, RoomId};
|
use ruma_identifiers::{UserId, RoomId};
|
||||||
|
|
||||||
/// Details about this API endpoint.
|
ruma_api! {
|
||||||
#[derive(Clone, Copy, Debug)]
|
metadata {
|
||||||
pub struct Endpoint;
|
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.
|
request {
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
/// The tagged room.
|
||||||
pub struct PathParams {
|
#[ruma_api(path)]
|
||||||
pub user_id: UserId,
|
|
||||||
pub room_id: RoomId,
|
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 {
|
response {}
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user