371 lines
10 KiB
Rust
371 lines
10 KiB
Rust
//! Endpoints for room membership.
|
|
|
|
use ruma_signatures::Signatures;
|
|
|
|
/// A signature of an `m.third_party_invite` token to prove that this user owns a third party identity which has been invited to the room.
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
pub struct ThirdPartySigned {
|
|
/// The Matrix ID of the invitee.
|
|
pub mxid: String,
|
|
/// The Matrix ID of the user who issued the invite.
|
|
pub sender: String,
|
|
/// A signatures object containing a signature of the entire signed object.
|
|
pub signatures: Signatures,
|
|
/// The state key of the m.third_party_invite event.
|
|
pub token: String,
|
|
}
|
|
|
|
/// [POST /_matrix/client/r0/rooms/{roomId}/invite](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-invite)
|
|
pub mod invite_user {
|
|
use ruma_identifiers::RoomId;
|
|
|
|
/// The request type.
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
pub struct BodyParams {
|
|
pub user_id: String,
|
|
}
|
|
|
|
/// Details about this API endpoint.
|
|
pub struct Endpoint;
|
|
|
|
/// This API endpoint's path parameters.
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
pub struct PathParams {
|
|
pub room_id: RoomId,
|
|
}
|
|
|
|
impl ::Endpoint for Endpoint {
|
|
type BodyParams = BodyParams;
|
|
type PathParams = PathParams;
|
|
type QueryParams = ();
|
|
type Response = ();
|
|
|
|
fn method() -> ::Method {
|
|
::Method::Post
|
|
}
|
|
|
|
fn request_path(params: Self::PathParams) -> String {
|
|
format!(
|
|
"/_matrix/client/r0/rooms/{}/invite",
|
|
params.room_id
|
|
)
|
|
}
|
|
|
|
fn router_path() -> String {
|
|
"/_matrix/client/r0/rooms/:room_id/invite".to_string()
|
|
}
|
|
}
|
|
}
|
|
|
|
/// [POST /_matrix/client/r0/join/{roomIdOrAlias}](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-join-roomidoralias)
|
|
pub mod join_room_by_id_or_alias {
|
|
use ruma_identifiers::{RoomId, RoomIdOrAliasId};
|
|
use super::ThirdPartySigned;
|
|
|
|
/// The request type.
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
pub struct BodyParams {
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub third_party_signed: Option<ThirdPartySigned>,
|
|
}
|
|
|
|
/// Details about this API endpoint.
|
|
pub struct Endpoint;
|
|
|
|
/// The response type.
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
pub struct Response {
|
|
pub room_id: RoomId,
|
|
}
|
|
|
|
/// This API endpoint's path parameters.
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
pub struct PathParams {
|
|
pub room_id_or_alias: RoomIdOrAliasId,
|
|
}
|
|
|
|
impl ::Endpoint for Endpoint {
|
|
type BodyParams = BodyParams;
|
|
type PathParams = PathParams;
|
|
type QueryParams = ();
|
|
type Response = Response;
|
|
|
|
fn method() -> ::Method {
|
|
::Method::Post
|
|
}
|
|
|
|
fn request_path(params: Self::PathParams) -> String {
|
|
match params.room_id_or_alias {
|
|
RoomIdOrAliasId::RoomId(room_id) => {
|
|
format!(
|
|
"/_matrix/client/r0/join/{}",
|
|
room_id
|
|
)
|
|
}
|
|
RoomIdOrAliasId::RoomAliasId(room_alias_id) => {
|
|
format!(
|
|
"/_matrix/client/r0/join/{}",
|
|
room_alias_id
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
fn router_path() -> String {
|
|
"/_matrix/client/r0/rooms/:room_id_or_alias/join".to_string()
|
|
}
|
|
}
|
|
}
|
|
|
|
/// [POST /_matrix/client/r0/rooms/{roomId}/join](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-join)
|
|
pub mod join_room_by_id {
|
|
use ruma_identifiers::RoomId;
|
|
use super::ThirdPartySigned;
|
|
|
|
/// The request type.
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
pub struct BodyParams {
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub third_party_signed: Option<ThirdPartySigned>,
|
|
}
|
|
|
|
/// Details about this API endpoint.
|
|
pub struct Endpoint;
|
|
|
|
/// The response type.
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
pub struct Response {
|
|
pub room_id: RoomId,
|
|
}
|
|
|
|
/// This API endpoint's path parameters.
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
pub struct PathParams {
|
|
pub room_id: RoomId,
|
|
}
|
|
|
|
impl ::Endpoint for Endpoint {
|
|
type BodyParams = BodyParams;
|
|
type PathParams = PathParams;
|
|
type QueryParams = ();
|
|
type Response = Response;
|
|
|
|
fn method() -> ::Method {
|
|
::Method::Post
|
|
}
|
|
|
|
fn request_path(params: Self::PathParams) -> String {
|
|
format!(
|
|
"/_matrix/client/r0/rooms/{}/join",
|
|
params.room_id
|
|
)
|
|
}
|
|
|
|
fn router_path() -> String {
|
|
"/_matrix/client/r0/rooms/:room_id/join".to_string()
|
|
}
|
|
}
|
|
}
|
|
|
|
/// [POST /_matrix/client/r0/rooms/{roomId}/forget](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-forget)
|
|
pub mod forget_room {
|
|
use ruma_identifiers::RoomId;
|
|
|
|
/// Details about this API endpoint.
|
|
pub struct Endpoint;
|
|
|
|
/// This API endpoint's path parameters.
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
pub struct PathParams {
|
|
pub room_id: RoomId,
|
|
}
|
|
|
|
impl ::Endpoint for Endpoint {
|
|
type BodyParams = ();
|
|
type PathParams = PathParams;
|
|
type QueryParams = ();
|
|
type Response = ();
|
|
|
|
fn method() -> ::Method {
|
|
::Method::Post
|
|
}
|
|
|
|
fn request_path(params: Self::PathParams) -> String {
|
|
format!(
|
|
"/_matrix/client/r0/rooms/{}/forget",
|
|
params.room_id
|
|
)
|
|
}
|
|
|
|
fn router_path() -> String {
|
|
"/_matrix/client/r0/rooms/:room_id/forget".to_string()
|
|
}
|
|
}
|
|
}
|
|
|
|
/// [POST /_matrix/client/r0/rooms/{roomId}/leave](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-leave)
|
|
pub mod leave_room {
|
|
use ruma_identifiers::RoomId;
|
|
|
|
/// Details about this API endpoint.
|
|
pub struct Endpoint;
|
|
|
|
/// This API endpoint's path parameters.
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
pub struct PathParams {
|
|
pub room_id: RoomId,
|
|
}
|
|
|
|
impl ::Endpoint for Endpoint {
|
|
type BodyParams = ();
|
|
type PathParams = PathParams;
|
|
type QueryParams = ();
|
|
type Response = ();
|
|
|
|
fn method() -> ::Method {
|
|
::Method::Post
|
|
}
|
|
|
|
fn request_path(params: Self::PathParams) -> String {
|
|
format!(
|
|
"/_matrix/client/r0/rooms/{}/leave",
|
|
params.room_id
|
|
)
|
|
}
|
|
|
|
fn router_path() -> String {
|
|
"/_matrix/client/r0/rooms/:room_id/leave".to_string()
|
|
}
|
|
}
|
|
}
|
|
|
|
/// [POST /_matrix/client/r0/rooms/{roomId}/kick](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-kick)
|
|
pub mod kick_user {
|
|
use ruma_identifiers::RoomId;
|
|
|
|
/// The request type.
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
pub struct BodyParams {
|
|
pub user_id: String,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub reason: Option<String>,
|
|
}
|
|
|
|
/// Details about this API endpoint.
|
|
pub struct Endpoint;
|
|
|
|
/// This API endpoint's path parameters.
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
pub struct PathParams {
|
|
pub room_id: RoomId,
|
|
}
|
|
|
|
impl ::Endpoint for Endpoint {
|
|
type BodyParams = BodyParams;
|
|
type PathParams = PathParams;
|
|
type QueryParams = ();
|
|
type Response = ();
|
|
|
|
fn method() -> ::Method {
|
|
::Method::Post
|
|
}
|
|
|
|
fn request_path(params: Self::PathParams) -> String {
|
|
format!(
|
|
"/_matrix/client/r0/rooms/{}/kick",
|
|
params.room_id
|
|
)
|
|
}
|
|
|
|
fn router_path() -> String {
|
|
"/_matrix/client/r0/rooms/:room_id/kick".to_string()
|
|
}
|
|
}
|
|
}
|
|
|
|
/// [POST /_matrix/client/r0/rooms/{roomId}/unban](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-unban)
|
|
pub mod unban_user {
|
|
use ruma_identifiers::RoomId;
|
|
|
|
/// The request type.
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
pub struct BodyParams {
|
|
pub user_id: String,
|
|
}
|
|
|
|
/// Details about this API endpoint.
|
|
pub struct Endpoint;
|
|
|
|
/// This API endpoint's path parameters.
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
pub struct PathParams {
|
|
pub room_id: RoomId,
|
|
}
|
|
|
|
impl ::Endpoint for Endpoint {
|
|
type BodyParams = BodyParams;
|
|
type PathParams = PathParams;
|
|
type QueryParams = ();
|
|
type Response = ();
|
|
|
|
fn method() -> ::Method {
|
|
::Method::Post
|
|
}
|
|
|
|
fn request_path(params: Self::PathParams) -> String {
|
|
format!(
|
|
"/_matrix/client/r0/rooms/{}/unban",
|
|
params.room_id
|
|
)
|
|
}
|
|
|
|
fn router_path() -> String {
|
|
"/_matrix/client/r0/rooms/:room_id/unban".to_string()
|
|
}
|
|
}
|
|
}
|
|
|
|
/// [POST /_matrix/client/r0/rooms/{roomId}/ban](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-ban)
|
|
pub mod ban_user {
|
|
use ruma_identifiers::RoomId;
|
|
|
|
/// The request type.
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
pub struct BodyParams {
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub reason: Option<String>,
|
|
pub user_id: String,
|
|
}
|
|
|
|
/// Details about this API endpoint.
|
|
pub struct Endpoint;
|
|
|
|
/// This API endpoint's path parameters.
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
pub struct PathParams {
|
|
pub room_id: RoomId,
|
|
}
|
|
|
|
impl ::Endpoint for Endpoint {
|
|
type BodyParams = BodyParams;
|
|
type PathParams = PathParams;
|
|
type QueryParams = ();
|
|
type Response = ();
|
|
|
|
fn method() -> ::Method {
|
|
::Method::Post
|
|
}
|
|
|
|
fn request_path(params: Self::PathParams) -> String {
|
|
format!(
|
|
"/_matrix/client/r0/rooms/{}/ban",
|
|
params.room_id
|
|
)
|
|
}
|
|
|
|
fn router_path() -> String {
|
|
"/_matrix/client/r0/rooms/:room_id/ban".to_string()
|
|
}
|
|
}
|
|
}
|