events: Add {RoomRedactionEvent, SyncRoomRedactionEvent}::as_original
@@ -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<RoomId>) -> RoomRedactionEvent {
match self {
