ruma_client_api/redact/
redact_event.rs

1//! `PUT /_matrix/client/*/rooms/{roomId}/redact/{eventId}/{txnId}`
2//!
3//! Redact an event, stripping all information not critical to the event graph integrity.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#put_matrixclientv3roomsroomidredacteventidtxnid
9
10    use ruma_common::{
11        api::{request, response, Metadata},
12        metadata, OwnedEventId, OwnedRoomId, OwnedTransactionId,
13    };
14
15    const METADATA: Metadata = metadata! {
16        method: PUT,
17        rate_limited: false,
18        authentication: AccessToken,
19        history: {
20            1.0 => "/_matrix/client/r0/rooms/:room_id/redact/:event_id/:txn_id",
21            1.1 => "/_matrix/client/v3/rooms/:room_id/redact/:event_id/:txn_id",
22        }
23    };
24
25    /// Request type for the `redact_event` endpoint.
26    #[request(error = crate::Error)]
27    pub struct Request {
28        /// The ID of the room of the event to redact.
29        #[ruma_api(path)]
30        pub room_id: OwnedRoomId,
31
32        /// The ID of the event to redact.
33        #[ruma_api(path)]
34        pub event_id: OwnedEventId,
35
36        /// The transaction ID for this event.
37        ///
38        /// Clients should generate a unique ID across requests within the
39        /// same session. A session is identified by an access token, and
40        /// persists when the [access token is refreshed].
41        ///
42        /// It will be used by the server to ensure idempotency of requests.
43        ///
44        /// [access token is refreshed]: https://spec.matrix.org/latest/client-server-api/#refreshing-access-tokens
45        #[ruma_api(path)]
46        pub txn_id: OwnedTransactionId,
47
48        /// The reason for the redaction.
49        #[serde(skip_serializing_if = "Option::is_none")]
50        pub reason: Option<String>,
51    }
52
53    /// Response type for the `redact_event` endpoint.
54    #[response(error = crate::Error)]
55    pub struct Response {
56        /// The ID of the redacted event.
57        pub event_id: OwnedEventId,
58    }
59
60    impl Request {
61        /// Creates a new `Request` with the given room ID, event ID and transaction ID.
62        pub fn new(
63            room_id: OwnedRoomId,
64            event_id: OwnedEventId,
65            txn_id: OwnedTransactionId,
66        ) -> Self {
67            Self { room_id, event_id, txn_id, reason: None }
68        }
69    }
70
71    impl Response {
72        /// Creates a new `Response` with the given event ID.
73        pub fn new(event_id: OwnedEventId) -> Self {
74            Self { event_id }
75        }
76    }
77}