diff --git a/src/lib.rs b/src/lib.rs index 68f7e837..67011de6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,7 +33,7 @@ pub mod r0 { pub mod profile; pub mod push; pub mod receipt; -// pub mod redact; + pub mod redact; pub mod room; // pub mod search; pub mod send; diff --git a/src/r0/redact.rs b/src/r0/redact.rs index 6e0de442..ead9fbee 100644 --- a/src/r0/redact.rs +++ b/src/r0/redact.rs @@ -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) pub mod redact_event { + use ruma_api_macros::ruma_api; use ruma_identifiers::{RoomId, EventId}; - /// Details about this API endpoint. - #[derive(Clone, Copy, Debug)] - pub struct Endpoint; - - /// This API endpoint's path parameters. - #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct PathParams { - pub room_id: RoomId, - 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 - } - - /// 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 + ruma_api! { + metadata { + description: "Redact an event, stripping all information not critical to the event graph integrity.", + method: Method::Put, + name: "redact_event", + path: "/_matrix/client/r0/rooms/:room_id/redact/:event_id/:txn_id", + rate_limited: false, + requires_authentication: true, } - fn request_path(params: Self::PathParams) -> String { - format!( - "/_matrix/client/r0/rooms/{}/redact/{}/{}", - params.room_id, - params.event_id, - params.txn_id - ) + request { + /// The ID of the event to redact. + #[ruma_api(path)] + pub event_id: EventId, + /// The reason for the redaction. + #[serde(skip_serializing_if = "Option::is_none")] + pub reason: Option, + /// 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 { - "/_matrix/client/r0/rooms/:room_id/redact/:event_id/:txn_id" - } - - 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 + response { + /// The ID of the redacted event. + pub event_id: EventId, } } }