From 873270db1dc6e898b7350d18f9ff46942ae5285c Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Mon, 11 Apr 2022 14:32:34 +0200 Subject: [PATCH] events: Add SyncRoomPowerLevelsEvent::power_levels --- crates/ruma-common/src/events/room/power_levels.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/ruma-common/src/events/room/power_levels.rs b/crates/ruma-common/src/events/room/power_levels.rs index 4e253400..845625b8 100644 --- a/crates/ruma-common/src/events/room/power_levels.rs +++ b/crates/ruma-common/src/events/room/power_levels.rs @@ -181,6 +181,16 @@ impl RoomPowerLevelsEvent { } } +impl SyncRoomPowerLevelsEvent { + /// Obtain the effective power levels, regardless of whether this event is redacted. + pub fn power_levels(&self) -> RoomPowerLevels { + match self { + Self::Original(ev) => ev.content.clone().into(), + Self::Redacted(ev) => ev.content.clone().into(), + } + } +} + /// The effective power levels of a room. /// /// This struct contains the same fields as [`RoomPowerLevelsEventContent`] and be created from that