Use ruma-api-macros for the redact endpoints.

This commit is contained in:
Jimmy Cuadra 2017-07-06 01:11:11 -07:00
parent 651fe9b3e3
commit fc29d7bf40
2 changed files with 28 additions and 60 deletions

View File

@ -33,7 +33,7 @@ pub mod r0 {
pub mod profile; pub mod profile;
pub mod push; pub mod push;
pub mod receipt; pub mod receipt;
// pub mod redact; pub mod redact;
pub mod room; pub mod room;
// pub mod search; // pub mod search;
pub mod send; pub mod send;

View File

@ -2,71 +2,39 @@
/// [PUT /_matrix/client/r0/rooms/{roomId}/redact/{eventId}/{txnId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-redact-eventid-txnid) /// [PUT /_matrix/client/r0/rooms/{roomId}/redact/{eventId}/{txnId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-redact-eventid-txnid)
pub mod redact_event { pub mod redact_event {
use ruma_api_macros::ruma_api;
use ruma_identifiers::{RoomId, EventId}; use ruma_identifiers::{RoomId, EventId};
/// Details about this API endpoint. ruma_api! {
#[derive(Clone, Copy, Debug)] metadata {
pub struct Endpoint; description: "Redact an event, stripping all information not critical to the event graph integrity.",
method: Method::Put,
/// This API endpoint's path parameters. name: "redact_event",
#[derive(Clone, Debug, Deserialize, Serialize)] path: "/_matrix/client/r0/rooms/:room_id/redact/:event_id/:txn_id",
pub struct PathParams { rate_limited: false,
pub room_id: RoomId, requires_authentication: true,
pub event_id: EventId,
pub txn_id: String
}
/// This API endpoint's path parameters.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct BodyParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub reason: Option<String>
}
/// This API endpoint's response.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Response {
pub event_id: EventId,
}
impl ::Endpoint for Endpoint {
type BodyParams = BodyParams;
type PathParams = PathParams;
type QueryParams = ();
type Response = Response;
fn method() -> ::Method {
::Method::Put
} }
fn request_path(params: Self::PathParams) -> String { request {
format!( /// The ID of the event to redact.
"/_matrix/client/r0/rooms/{}/redact/{}/{}", #[ruma_api(path)]
params.room_id, pub event_id: EventId,
params.event_id, /// The reason for the redaction.
params.txn_id #[serde(skip_serializing_if = "Option::is_none")]
) pub reason: Option<String>,
/// The ID of the room of the event to redact.
#[ruma_api(path)]
pub room_id: RoomId,
/// The transaction ID for this event.
///
/// Clients should generate a unique ID; 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/redact/:event_id/:txn_id" /// The ID of the redacted event.
} pub event_id: EventId,
fn name() -> &'static str {
"redact_event"
}
fn description() -> &'static str {
"Redact an event, stripping all information not critical to the event graph integrity."
}
fn requires_authentication() -> bool {
true
}
fn rate_limited() -> bool {
false
} }
} }
} }