Use ruma-api-macros for the create_room endpoint
This commit is contained in:
parent
0a997d28a4
commit
5c43a32b00
@ -33,7 +33,7 @@ pub mod r0 {
|
||||
// pub mod push;
|
||||
// pub mod receipt;
|
||||
// pub mod redact;
|
||||
// pub mod room;
|
||||
pub mod room;
|
||||
// pub mod search;
|
||||
pub mod send;
|
||||
// pub mod server;
|
||||
|
@ -3,10 +3,19 @@
|
||||
/// [POST /_matrix/client/r0/createRoom](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-createroom)
|
||||
pub mod create_room {
|
||||
use ruma_identifiers::{RoomId, UserId};
|
||||
use ruma_api_macros::ruma_api;
|
||||
|
||||
/// The request type.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct BodyParams {
|
||||
ruma_api! {
|
||||
metadata {
|
||||
description: "Create a new room.",
|
||||
method: Method::Post,
|
||||
name: "create_room",
|
||||
path: "/_matrix/client/r0/createRoom",
|
||||
rate_limited: false,
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
request {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub creation_content: Option<CreationContent>,
|
||||
#[serde(skip_serializing_if = "Vec::is_empty")]
|
||||
@ -25,6 +34,11 @@ pub mod create_room {
|
||||
// TODO: missing `invite_3pid`, `initial_state`
|
||||
}
|
||||
|
||||
response {
|
||||
pub room_id: RoomId,
|
||||
}
|
||||
}
|
||||
|
||||
/// Extra options to be added to the `m.room.create` event.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct CreationContent {
|
||||
@ -33,16 +47,6 @@ pub mod create_room {
|
||||
pub federate: Option<bool>,
|
||||
}
|
||||
|
||||
/// Details about this API endpoint.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Endpoint;
|
||||
|
||||
/// The response type.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct Response {
|
||||
pub room_id: RoomId,
|
||||
}
|
||||
|
||||
/// A convenience parameter for setting a few default state events.
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
||||
pub enum RoomPreset {
|
||||
@ -56,39 +60,4 @@ pub mod create_room {
|
||||
#[serde(rename="trusted_private_chat")]
|
||||
TrustedPrivateChat,
|
||||
}
|
||||
|
||||
impl ::Endpoint for Endpoint {
|
||||
type BodyParams = BodyParams;
|
||||
type PathParams = ();
|
||||
type QueryParams = ();
|
||||
type Response = Response;
|
||||
|
||||
fn method() -> ::Method {
|
||||
::Method::Post
|
||||
}
|
||||
|
||||
fn request_path(_params: Self::PathParams) -> String {
|
||||
Self::router_path().to_string()
|
||||
}
|
||||
|
||||
fn router_path() -> &'static str {
|
||||
"/_matrix/client/r0/createRoom"
|
||||
}
|
||||
|
||||
fn name() -> &'static str {
|
||||
"create_room"
|
||||
}
|
||||
|
||||
fn description() -> &'static str {
|
||||
"Create a new room."
|
||||
}
|
||||
|
||||
fn requires_authentication() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn rate_limited() -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user