Use ruma-api-macros for the directory endpoints.
This commit is contained in:
parent
4b728514ca
commit
dfb45a762f
@ -24,7 +24,7 @@ pub mod r0 {
|
|||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod contact;
|
pub mod contact;
|
||||||
pub mod context;
|
pub mod context;
|
||||||
// pub mod directory;
|
pub mod directory;
|
||||||
// pub mod filter;
|
// pub mod filter;
|
||||||
// pub mod media;
|
// pub mod media;
|
||||||
// pub mod membership;
|
// pub mod membership;
|
||||||
|
@ -3,67 +3,53 @@
|
|||||||
/// [GET /_matrix/client/r0/publicRooms](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-publicrooms)
|
/// [GET /_matrix/client/r0/publicRooms](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-publicrooms)
|
||||||
pub mod get_public_rooms {
|
pub mod get_public_rooms {
|
||||||
use ruma_identifiers::{RoomId, RoomAliasId};
|
use ruma_identifiers::{RoomId, RoomAliasId};
|
||||||
|
use ruma_api_macros::ruma_api;
|
||||||
|
|
||||||
|
ruma_api! {
|
||||||
|
metadata {
|
||||||
|
description: "Get the list of rooms in this homeserver's public directory.",
|
||||||
|
method: Method::Get,
|
||||||
|
name: "get_public_rooms",
|
||||||
|
path: "/_matrix/client/r0/publicRooms",
|
||||||
|
rate_limited: false,
|
||||||
|
requires_authentication: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
request {}
|
||||||
|
|
||||||
|
response {
|
||||||
|
/// A pagination token for the response.
|
||||||
|
pub start: String,
|
||||||
|
/// A paginated chunk of public rooms.
|
||||||
|
pub chunk: Vec<PublicRoomsChunk>,
|
||||||
|
/// A pagination token for the response.
|
||||||
|
pub end: String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A chunk of the response, describing one room
|
/// A chunk of the response, describing one room
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct PublicRoomsChunk {
|
pub struct PublicRoomsChunk {
|
||||||
pub world_readable: bool,
|
/// Aliases of the room.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
pub aliases: Vec<RoomAliasId>,
|
||||||
pub topic: Option<String>,
|
/// The URL for the room's avatar, if one is set.
|
||||||
pub num_joined_members: u64,
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub avatar_url: Option<String>,
|
pub avatar_url: Option<String>,
|
||||||
pub room_id: RoomId,
|
/// Whether guest users may join the room and participate in it.
|
||||||
|
///
|
||||||
|
/// If they can, they will be subject to ordinary power level rules like any other user.
|
||||||
pub guest_can_join: bool,
|
pub guest_can_join: bool,
|
||||||
pub aliases: Vec<RoomAliasId>,
|
/// The name of the room, if any.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub name: Option<String>
|
pub name: Option<String>,
|
||||||
}
|
/// The number of members joined to the room.
|
||||||
|
pub num_joined_members: u64,
|
||||||
/// This API response type
|
/// The ID of the room.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
pub room_id: RoomId,
|
||||||
pub struct Response {
|
/// The topic of the room, if any.
|
||||||
pub start: String,
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub chunk: Vec<PublicRoomsChunk>,
|
pub topic: Option<String>,
|
||||||
pub end: String
|
/// Whether the room may be viewed by guest users without joining.
|
||||||
}
|
pub world_readable: bool,
|
||||||
|
|
||||||
/// Details about this API endpoint.
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
|
||||||
pub struct Endpoint;
|
|
||||||
|
|
||||||
impl ::Endpoint for Endpoint {
|
|
||||||
type BodyParams = ();
|
|
||||||
type PathParams = ();
|
|
||||||
type QueryParams = ();
|
|
||||||
type Response = Response;
|
|
||||||
|
|
||||||
fn method() -> ::Method {
|
|
||||||
::Method::Get
|
|
||||||
}
|
|
||||||
|
|
||||||
fn request_path(_params: Self::PathParams) -> String {
|
|
||||||
Self::router_path().to_string()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn router_path() -> &'static str {
|
|
||||||
"/_matrix/client/r0/publicRooms"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name() -> &'static str {
|
|
||||||
"get_public_rooms"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn description() -> &'static str {
|
|
||||||
"Get the list of rooms in this homeserver's public directory."
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requires_authentication() -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rate_limited() -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user