diff --git a/crates/ruma-common/src/events/room/guest_access.rs b/crates/ruma-common/src/events/room/guest_access.rs index e263c886..9fa7f09d 100644 --- a/crates/ruma-common/src/events/room/guest_access.rs +++ b/crates/ruma-common/src/events/room/guest_access.rs @@ -28,6 +28,26 @@ impl RoomGuestAccessEventContent { } } +impl RoomGuestAccessEvent { + /// Obtain the guest access policy, regardless of whether this event is redacted. + pub fn guest_access(&self) -> &GuestAccess { + match self { + Self::Original(ev) => &ev.content.guest_access, + Self::Redacted(_) => &GuestAccess::Forbidden, + } + } +} + +impl SyncRoomGuestAccessEvent { + /// Obtain the guest access policy, regardless of whether this event is redacted. + pub fn guest_access(&self) -> &GuestAccess { + match self { + Self::Original(ev) => &ev.content.guest_access, + Self::Redacted(_) => &GuestAccess::Forbidden, + } + } +} + /// A policy for guest user access to a room. #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))] #[derive(Clone, Debug, PartialEq, Eq, StringEnum)]