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