events: Add {RoomRedactionEvent, SyncRoomRedactionEvent}::as_original

This commit is contained in:
Jonas Platte 2022-04-13 16:43:41 +02:00
parent d0faeb52f3
commit dd24d6be77
No known key found for this signature in database
GPG Key ID: BBA95679259D342F

View File

@ -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 {