diff --git a/crates/ruma-common/CHANGELOG.md b/crates/ruma-common/CHANGELOG.md index 565ebb73..b64d0818 100644 --- a/crates/ruma-common/CHANGELOG.md +++ b/crates/ruma-common/CHANGELOG.md @@ -3,6 +3,7 @@ Breaking changes: * Add `user_id` field to `PushConditionRoomCtx` +* Remove `PartialEq` implementation on `NotificationPowerLevels` Improvements: diff --git a/crates/ruma-common/src/events/room/power_levels.rs b/crates/ruma-common/src/events/room/power_levels.rs index 44d7931e..62968262 100644 --- a/crates/ruma-common/src/events/room/power_levels.rs +++ b/crates/ruma-common/src/events/room/power_levels.rs @@ -135,7 +135,7 @@ pub struct RoomPowerLevelsEventContent { /// The power level requirements for specific notification types. /// /// This is a mapping from `key` to power level for that notifications key. - #[serde(default, skip_serializing_if = "crate::serde::is_default")] + #[serde(default, skip_serializing_if = "NotificationPowerLevels::is_default")] pub notifications: NotificationPowerLevels, } diff --git a/crates/ruma-common/src/power_levels.rs b/crates/ruma-common/src/power_levels.rs index f59b4740..87274c96 100644 --- a/crates/ruma-common/src/power_levels.rs +++ b/crates/ruma-common/src/power_levels.rs @@ -6,7 +6,7 @@ use js_int::{int, Int}; use serde::{Deserialize, Serialize}; /// The power level requirements for specific notification types. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] pub struct NotificationPowerLevels { /// The level required to trigger an `@room` notification. @@ -34,6 +34,10 @@ impl NotificationPowerLevels { _ => None, } } + + pub(crate) fn is_default(&self) -> bool { + self.room == default_power_level() + } } impl Default for NotificationPowerLevels {