Use ruma-api-macros for the send endpoints.
This commit is contained in:
parent
fb90929aa1
commit
5f880dfbb1
@ -35,7 +35,7 @@ pub mod r0 {
|
|||||||
// pub mod redact;
|
// pub mod redact;
|
||||||
// pub mod room;
|
// pub mod room;
|
||||||
// pub mod search;
|
// pub mod search;
|
||||||
// pub mod send;
|
pub mod send;
|
||||||
// pub mod server;
|
// pub mod server;
|
||||||
// pub mod session;
|
// pub mod session;
|
||||||
// pub mod sync;
|
// pub mod sync;
|
||||||
|
221
src/r0/send.rs
221
src/r0/send.rs
@ -2,193 +2,106 @@
|
|||||||
|
|
||||||
/// [PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-state-eventtype)
|
/// [PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-state-eventtype)
|
||||||
pub mod send_state_event_for_empty_key {
|
pub mod send_state_event_for_empty_key {
|
||||||
|
use ruma_api_macros::ruma_api;
|
||||||
use ruma_identifiers::{RoomId, EventId};
|
use ruma_identifiers::{RoomId, EventId};
|
||||||
use ruma_events::EventType;
|
use ruma_events::EventType;
|
||||||
|
|
||||||
/// Details about this API endpoint.
|
ruma_api! {
|
||||||
#[derive(Clone, Copy, Debug)]
|
metadata {
|
||||||
pub struct Endpoint;
|
description: "Send a state event to a room associated with the empty state key.",
|
||||||
|
method: Method::Put,
|
||||||
/// This API endpoint's path parameters.
|
name: "send_state_event_for_empty_key",
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
path: "/_matrix/client/r0/rooms/:room_id/state/:event_type",
|
||||||
pub struct PathParams {
|
rate_limited: false,
|
||||||
pub room_id: RoomId,
|
requires_authentication: true,
|
||||||
pub event_type: EventType
|
|
||||||
}
|
|
||||||
|
|
||||||
/// This API endpoint's response.
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
||||||
pub struct Response {
|
|
||||||
pub event_id: EventId,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
impl ::Endpoint for Endpoint {
|
|
||||||
type BodyParams = ::serde_json::Value;
|
|
||||||
type PathParams = PathParams;
|
|
||||||
type QueryParams = ();
|
|
||||||
type Response = Response;
|
|
||||||
|
|
||||||
fn method() -> ::Method {
|
|
||||||
::Method::Put
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn request_path(params: Self::PathParams) -> String {
|
request {
|
||||||
format!(
|
/// The room to set the state in.
|
||||||
"/_matrix/client/r0/rooms/{}/state/{}",
|
#[ruma_api(path)]
|
||||||
params.room_id,
|
pub room_id: RoomId,
|
||||||
params.event_type
|
/// The type of event to send.
|
||||||
)
|
#[ruma_api(path)]
|
||||||
|
pub event_type: EventType,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn router_path() -> &'static str {
|
response {
|
||||||
"/_matrix/client/r0/rooms/:room_id/state/:event_type"
|
/// A unique identifier for the event.
|
||||||
}
|
pub event_id: EventId,
|
||||||
|
|
||||||
fn name() -> &'static str {
|
|
||||||
"send_state_event_for_empty_key"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn description() -> &'static str {
|
|
||||||
"Send a state event to a room associated with the empty state key."
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requires_authentication() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rate_limited() -> bool {
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-state-eventtype-statekey)
|
/// [PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-state-eventtype-statekey)
|
||||||
pub mod send_state_event_for_key {
|
pub mod send_state_event_for_key {
|
||||||
|
use ruma_api_macros::ruma_api;
|
||||||
use ruma_identifiers::{RoomId, EventId};
|
use ruma_identifiers::{RoomId, EventId};
|
||||||
use ruma_events::EventType;
|
use ruma_events::EventType;
|
||||||
|
|
||||||
/// Details about this API endpoint.
|
ruma_api! {
|
||||||
#[derive(Clone, Copy, Debug)]
|
metadata {
|
||||||
pub struct Endpoint;
|
description: "Send a state event to a room associated with a given state key.",
|
||||||
|
method: Method::Put,
|
||||||
/// This API endpoint's path parameters.
|
name: "send_state_event_for_key",
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
path: "/_matrix/client/r0/rooms/:room_id/state/:event_type/:state_key",
|
||||||
pub struct PathParams {
|
rate_limited: false,
|
||||||
pub room_id: RoomId,
|
requires_authentication: true,
|
||||||
pub event_type: EventType,
|
|
||||||
pub state_key: String
|
|
||||||
}
|
|
||||||
|
|
||||||
/// This API endpoint's response.
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
||||||
pub struct Response {
|
|
||||||
pub event_id: EventId,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
impl ::Endpoint for Endpoint {
|
|
||||||
type BodyParams = ::serde_json::Value;
|
|
||||||
type PathParams = PathParams;
|
|
||||||
type QueryParams = ();
|
|
||||||
type Response = Response;
|
|
||||||
|
|
||||||
fn method() -> ::Method {
|
|
||||||
::Method::Put
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn request_path(params: Self::PathParams) -> String {
|
request {
|
||||||
format!(
|
/// The room to set the state in.
|
||||||
"/_matrix/client/r0/rooms/{}/state/{}/{}",
|
#[ruma_api(path)]
|
||||||
params.room_id,
|
pub room_id: RoomId,
|
||||||
params.event_type,
|
/// The type of event to send.
|
||||||
params.state_key
|
#[ruma_api(path)]
|
||||||
)
|
pub event_type: EventType,
|
||||||
|
/// The state_key for the state to send. Defaults to the empty string.
|
||||||
|
#[ruma_api(path)]
|
||||||
|
pub state_key: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn router_path() -> &'static str {
|
response {
|
||||||
"/_matrix/client/r0/rooms/:room_id/state/:event_type/:state_key"
|
/// A unique identifier for the event.
|
||||||
}
|
pub event_id: EventId,
|
||||||
|
|
||||||
fn name() -> &'static str {
|
|
||||||
"send_state_event_for_key"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn description() -> &'static str {
|
|
||||||
"Send a state event to a room associated with a given state key."
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requires_authentication() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rate_limited() -> bool {
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-send-eventtype-txnid)
|
/// [PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-send-eventtype-txnid)
|
||||||
pub mod send_message_event {
|
pub mod send_message_event {
|
||||||
|
use ruma_api_macros::ruma_api;
|
||||||
use ruma_identifiers::{RoomId, EventId};
|
use ruma_identifiers::{RoomId, EventId};
|
||||||
use ruma_events::EventType;
|
use ruma_events::EventType;
|
||||||
|
|
||||||
/// Details about this API endpoint.
|
ruma_api! {
|
||||||
#[derive(Clone, Copy, Debug)]
|
metadata {
|
||||||
pub struct Endpoint;
|
description: "Send a message event to a room.",
|
||||||
|
method: Method::Put,
|
||||||
/// This API endpoint's path parameters.
|
name: "send_message_event",
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
path: "/_matrix/client/r0/rooms/:room_id/send/:event_type/:txn_id",
|
||||||
pub struct PathParams {
|
rate_limited: false,
|
||||||
pub room_id: RoomId,
|
requires_authentication: true,
|
||||||
pub event_type: EventType,
|
|
||||||
pub txn_id: String
|
|
||||||
}
|
|
||||||
|
|
||||||
/// This API endpoint's response.
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
||||||
pub struct Response {
|
|
||||||
pub event_id: EventId,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
impl ::Endpoint for Endpoint {
|
|
||||||
type BodyParams = ::serde_json::Value;
|
|
||||||
type PathParams = PathParams;
|
|
||||||
type QueryParams = ();
|
|
||||||
type Response = Response;
|
|
||||||
|
|
||||||
fn method() -> ::Method {
|
|
||||||
::Method::Put
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn request_path(params: Self::PathParams) -> String {
|
request {
|
||||||
format!(
|
/// The room to send the event to.
|
||||||
"/_matrix/client/r0/rooms/{}/send/{}/{}",
|
#[ruma_api(path)]
|
||||||
params.room_id,
|
pub room_id: RoomId,
|
||||||
params.event_type,
|
/// The type of event to send.
|
||||||
params.txn_id
|
#[ruma_api(path)]
|
||||||
)
|
pub event_type: EventType,
|
||||||
|
/// The transaction ID for this event.
|
||||||
|
///
|
||||||
|
/// Clients should generate an ID unique across requests with the
|
||||||
|
/// same access token; it will be used by the server to ensure
|
||||||
|
/// idempotency of requests.
|
||||||
|
#[ruma_api(path)]
|
||||||
|
pub txn_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn router_path() -> &'static str {
|
response {
|
||||||
"/_matrix/client/r0/rooms/:room_id/send/:event_type/:txn_id"
|
/// A unique identifier for the event.
|
||||||
}
|
pub event_id: EventId,
|
||||||
|
|
||||||
fn name() -> &'static str {
|
|
||||||
"send_message_event"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn description() -> &'static str {
|
|
||||||
"Send a message event to a room."
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requires_authentication() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rate_limited() -> bool {
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user