diff --git a/crates/ruma-common/Cargo.toml b/crates/ruma-common/Cargo.toml index 9b83af31..ffa9b112 100644 --- a/crates/ruma-common/Cargo.toml +++ b/crates/ruma-common/Cargo.toml @@ -30,6 +30,7 @@ unstable-msc3026 = [] unstable-msc3930 = [] unstable-msc3931 = [] unstable-msc3932 = ["unstable-msc3931"] +unstable-msc4210 = [] unstable-unspecified = [] # Allow IDs to exceed 255 bytes. diff --git a/crates/ruma-common/src/push.rs b/crates/ruma-common/src/push.rs index 634d367c..47a778c5 100644 --- a/crates/ruma-common/src/push.rs +++ b/crates/ruma-common/src/push.rs @@ -487,6 +487,18 @@ impl ConditionalPushRule { return false; } + // The old mention rules are disabled when an m.mentions field is present. + // + // MSC4210 always disables the legacy rules. + #[allow(deprecated)] + if (self.rule_id == PredefinedOverrideRuleId::RoomNotif.as_ref() + || self.rule_id == PredefinedOverrideRuleId::ContainsDisplayName.as_ref() + || self.rule_id == PredefinedContentRuleId::ContainsUserName.as_ref()) + && (event.contains_mentions() || cfg!(feature = "unstable-msc4210")) + { + return false; + } + #[cfg(feature = "unstable-msc3932")] { // These 3 rules always apply. @@ -510,15 +522,6 @@ impl ConditionalPushRule { } } - // The old mention rules are disabled when an m.mentions field is present. - #[allow(deprecated)] - if (self.rule_id == PredefinedOverrideRuleId::RoomNotif.as_ref() - || self.rule_id == PredefinedOverrideRuleId::ContainsDisplayName.as_ref()) - && event.contains_mentions() - { - return false; - } - self.conditions.iter().all(|cond| cond.applies(event, context)) } } diff --git a/crates/ruma-common/src/push/predefined.rs b/crates/ruma-common/src/push/predefined.rs index 74a4c891..402287c3 100644 --- a/crates/ruma-common/src/push/predefined.rs +++ b/crates/ruma-common/src/push/predefined.rs @@ -22,6 +22,7 @@ impl Ruleset { pub fn server_default(user_id: &UserId) -> Self { Self { content: [ + #[cfg(not(feature = "unstable-msc4210"))] #[allow(deprecated)] PatternedPushRule::contains_user_name(user_id), ] @@ -32,9 +33,11 @@ impl Ruleset { ConditionalPushRule::invite_for_me(user_id), ConditionalPushRule::member_event(), ConditionalPushRule::is_user_mention(user_id), + #[cfg(not(feature = "unstable-msc4210"))] #[allow(deprecated)] ConditionalPushRule::contains_display_name(), ConditionalPushRule::is_room_mention(), + #[cfg(not(feature = "unstable-msc4210"))] #[allow(deprecated)] ConditionalPushRule::roomnotif(), ConditionalPushRule::tombstone(), diff --git a/crates/ruma/Cargo.toml b/crates/ruma/Cargo.toml index 5e012766..689784ba 100644 --- a/crates/ruma/Cargo.toml +++ b/crates/ruma/Cargo.toml @@ -270,6 +270,7 @@ unstable-msc4121 = ["ruma-client-api?/unstable-msc4121"] unstable-msc4125 = ["ruma-federation-api?/unstable-msc4125"] unstable-msc4140 = ["ruma-client-api?/unstable-msc4140"] unstable-msc4186 = ["ruma-client-api?/unstable-msc4186"] +unstable-msc4210 = ["ruma-common/unstable-msc4210"] unstable-pdu = ["ruma-events?/unstable-pdu"] unstable-unspecified = [ "ruma-common/unstable-unspecified",