diff --git a/crates/ruma-client-api/src/error.rs b/crates/ruma-client-api/src/error.rs index 27ccbe6c66..7271c53562 100644 --- a/crates/ruma-client-api/src/error.rs +++ b/crates/ruma-client-api/src/error.rs @@ -33,6 +33,19 @@ mod kind_serde; #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum ErrorKind { + /// M_UNREDACTED_CONTENT_DELETED and FI.MAU.MSC2815_UNREDACTED_CONTENT_DELETED + /// + /// as per MSC2815 + UnredactedContentDeleted { + /// fi.mau.msc2815.content_keep_ms + content_keep_ms: Option, + }, + + /// M_UNREDACTED_CONTENT_NOT_RECEIVED and FI.MAU.MSC2815_UNREDACTED_CONTENT_NOT_RECEIVED + /// + /// as per MSC2815 + UnredactedContentNotReceived, + /// M_FORBIDDEN #[non_exhaustive] Forbidden { @@ -238,6 +251,10 @@ pub struct Extra(BTreeMap); impl AsRef for ErrorKind { fn as_ref(&self) -> &str { match self { + // TODO: replace with M_UNREDACTED_CONTENT_DELETED when stabilised + Self::UnredactedContentDeleted { .. } => "FI.MAU.MSC2815_UNREDACTED_CONTENT_DELETED", + // TODO: replace with M_UNREDACTED_CONTENT_NOT_RECEIVED when stabilised + Self::UnredactedContentNotReceived => "FI.MAU.MSC2815_UNREDACTED_CONTENT_NOT_RECEIVED", Self::Forbidden { .. } => "M_FORBIDDEN", Self::UnknownToken { .. } => "M_UNKNOWN_TOKEN", Self::MissingToken => "M_MISSING_TOKEN", diff --git a/crates/ruma-client-api/src/room/get_room_event.rs b/crates/ruma-client-api/src/room/get_room_event.rs index 1db4927484..8092997a6b 100644 --- a/crates/ruma-client-api/src/room/get_room_event.rs +++ b/crates/ruma-client-api/src/room/get_room_event.rs @@ -35,6 +35,17 @@ pub mod v3 { /// The ID of the event. #[ruma_api(path)] pub event_id: OwnedEventId, + + /// Query parameter to tell the server if it should return the redacted content of the + /// requested event + /// + /// as per MSC2815: https://github.com/matrix-org/matrix-spec-proposals/pull/2815 + #[ruma_api(query)] + #[serde( + skip_serializing_if = "Option::is_none", + alias = "fi.mau.msc2815.include_unredacted_content" + )] + pub include_unredacted_content: Option, } /// Response type for the `get_room_event` endpoint. @@ -47,8 +58,12 @@ pub mod v3 { impl Request { /// Creates a new `Request` with the given room ID and event ID. - pub fn new(room_id: OwnedRoomId, event_id: OwnedEventId) -> Self { - Self { room_id, event_id } + pub fn new( + room_id: OwnedRoomId, + event_id: OwnedEventId, + include_unredacted_content: Option, + ) -> Self { + Self { room_id, event_id, include_unredacted_content } } } diff --git a/crates/ruma-federation-api/src/event/get_event.rs b/crates/ruma-federation-api/src/event/get_event.rs index d2c666b1f8..14edd592ce 100644 --- a/crates/ruma-federation-api/src/event/get_event.rs +++ b/crates/ruma-federation-api/src/event/get_event.rs @@ -28,6 +28,17 @@ pub mod v1 { /// The event ID to get. #[ruma_api(path)] pub event_id: OwnedEventId, + + /// Query parameter to tell the server if it should return the redacted content of the + /// requested event + /// + /// as per MSC2815: https://github.com/matrix-org/matrix-spec-proposals/pull/2815 + #[ruma_api(query)] + #[serde( + skip_serializing_if = "Option::is_none", + alias = "fi.mau.msc2815.include_unredacted_content" + )] + pub include_unredacted_content: Option, } /// Response type for the `get_event` endpoint. @@ -46,8 +57,8 @@ pub mod v1 { impl Request { /// Creates a new `Request` with the given event id. - pub fn new(event_id: OwnedEventId) -> Self { - Self { event_id } + pub fn new(event_id: OwnedEventId, include_unredacted_content: Option) -> Self { + Self { event_id, include_unredacted_content } } }