events: Add RoomPowerLevelsEvent::power_levels

This commit is contained in:
Jonas Platte 2022-04-11 12:59:31 +02:00
parent 97a3c1e473
commit 9f6f176f8d
No known key found for this signature in database
GPG Key ID: BBA95679259D342F

View File

@ -171,6 +171,16 @@ fn is_default_power_level(l: &Int) -> bool {
*l == int!(50)
}
impl RoomPowerLevelsEvent {
/// 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