diff --git a/crates/ruma-common/src/events/room/redaction.rs b/crates/ruma-common/src/events/room/redaction.rs index 17772d2c..2cfe9f1e 100644 --- a/crates/ruma-common/src/events/room/redaction.rs +++ b/crates/ruma-common/src/events/room/redaction.rs @@ -230,6 +230,14 @@ impl RoomRedactionEvent { Self::Redacted(ev) => &ev.room_id, } } + + /// Get the inner `RoomRedactionEvent` if this is an unredacted event. + pub fn as_original(&self) -> Option<&OriginalRoomRedactionEvent> { + match self { + Self::Original(v) => Some(v), + _ => None, + } + } } impl Redact for RoomRedactionEvent { @@ -292,6 +300,14 @@ impl SyncRoomRedactionEvent { } } + /// Get the inner `SyncRoomRedactionEvent` if this is an unredacted event. + pub fn as_original(&self) -> Option<&OriginalSyncRoomRedactionEvent> { + match self { + Self::Original(v) => Some(v), + _ => None, + } + } + /// Convert this sync event into a full event (one with a `room_id` field). pub fn into_full_event(self, room_id: Box) -> RoomRedactionEvent { match self {