diff --git a/rust/src/push/mod.rs b/rust/src/push/mod.rs index 19a7db6cb144..59c2f24cc00b 100644 --- a/rust/src/push/mod.rs +++ b/rust/src/push/mod.rs @@ -417,6 +417,7 @@ pub struct FilteredPushRules { enabled_map: BTreeMap, msc3664_enabled: bool, msc1767_enabled: bool, + msc3952_intentional_mentions: bool, } #[pymethods] @@ -427,12 +428,14 @@ impl FilteredPushRules { enabled_map: BTreeMap, msc3664_enabled: bool, msc1767_enabled: bool, + msc3952_intentional_mentions: bool, ) -> Self { Self { push_rules, enabled_map, msc3664_enabled, msc1767_enabled, + msc3952_intentional_mentions, } } @@ -461,6 +464,11 @@ impl FilteredPushRules { return false; } + if !self.msc3952_intentional_mentions && rule.rule_id.contains("org.matrix.msc3952") + { + return false; + } + true }) .map(|r| { diff --git a/stubs/synapse/synapse_rust/push.pyi b/stubs/synapse/synapse_rust/push.pyi index 739bf4409cef..85562c8f44d4 100644 --- a/stubs/synapse/synapse_rust/push.pyi +++ b/stubs/synapse/synapse_rust/push.pyi @@ -45,6 +45,7 @@ class FilteredPushRules: enabled_map: Dict[str, bool], msc3664_enabled: bool, msc1767_enabled: bool, + msc3952_intentional_mentions: bool, ): ... def rules(self) -> Collection[Tuple[PushRule, bool]]: ... diff --git a/synapse/config/experimental.py b/synapse/config/experimental.py index a8b2db372d56..cf60a3b07848 100644 --- a/synapse/config/experimental.py +++ b/synapse/config/experimental.py @@ -142,3 +142,8 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None: # MSC3925: do not replace events with their edits self.msc3925_inhibit_edit = experimental.get("msc3925_inhibit_edit", False) + + # MSC3952: Intentional mentions + self.msc3952_intentional_mentions = experimental.get( + "msc3952_intentional_mentions", False + ) diff --git a/synapse/storage/databases/main/push_rule.py b/synapse/storage/databases/main/push_rule.py index d4e4b777da95..8e4059ff9837 100644 --- a/synapse/storage/databases/main/push_rule.py +++ b/synapse/storage/databases/main/push_rule.py @@ -88,6 +88,7 @@ def _load_rules( enabled_map, msc3664_enabled=experimental_config.msc3664_enabled, msc1767_enabled=experimental_config.msc1767_enabled, + msc3952_intentional_mentions=experimental_config.msc3952_intentional_mentions, ) return filtered_rules