Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 7c5b002

Browse files
committed
Add an experimental config option.
1 parent c9d2a3d commit 7c5b002

File tree

5 files changed

+16
-0
lines changed

5 files changed

+16
-0
lines changed

rust/src/push/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ pub struct FilteredPushRules {
417417
enabled_map: BTreeMap<String, bool>,
418418
msc3664_enabled: bool,
419419
msc1767_enabled: bool,
420+
msc3952_intentional_mentions: bool,
420421
}
421422

422423
#[pymethods]
@@ -427,12 +428,14 @@ impl FilteredPushRules {
427428
enabled_map: BTreeMap<String, bool>,
428429
msc3664_enabled: bool,
429430
msc1767_enabled: bool,
431+
msc3952_intentional_mentions: bool,
430432
) -> Self {
431433
Self {
432434
push_rules,
433435
enabled_map,
434436
msc3664_enabled,
435437
msc1767_enabled,
438+
msc3952_intentional_mentions,
436439
}
437440
}
438441

@@ -461,6 +464,11 @@ impl FilteredPushRules {
461464
return false;
462465
}
463466

467+
if !self.msc3952_intentional_mentions && rule.rule_id.contains("org.matrix.msc3952")
468+
{
469+
return false;
470+
}
471+
464472
true
465473
})
466474
.map(|r| {

stubs/synapse/synapse_rust/push.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class FilteredPushRules:
4545
enabled_map: Dict[str, bool],
4646
msc3664_enabled: bool,
4747
msc1767_enabled: bool,
48+
msc3952_intentional_mentions: bool,
4849
): ...
4950
def rules(self) -> Collection[Tuple[PushRule, bool]]: ...
5051

synapse/config/experimental.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,8 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:
142142

143143
# MSC3925: do not replace events with their edits
144144
self.msc3925_inhibit_edit = experimental.get("msc3925_inhibit_edit", False)
145+
146+
# MSC3952: Intentional mentions
147+
self.msc3952_intentional_mentions = experimental.get(
148+
"msc3952_intentional_mentions", False
149+
)

synapse/storage/databases/main/push_rule.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def _load_rules(
8888
enabled_map,
8989
msc3664_enabled=experimental_config.msc3664_enabled,
9090
msc1767_enabled=experimental_config.msc1767_enabled,
91+
msc3952_intentional_mentions=experimental_config.msc3952_intentional_mentions,
9192
)
9293

9394
return filtered_rules

tests/push/test_bulk_push_rule_evaluator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ def test_action_for_event_by_user_disabled_by_config(self) -> None:
128128
self.get_success(bulk_evaluator.action_for_events_by_user([(event, context)]))
129129
bulk_evaluator._action_for_event_by_user.assert_not_called()
130130

131+
@override_config({"experimental_features": {"msc3952_intentional_mentions": True}})
131132
def test_mentions(self) -> None:
132133
"""Test the behavior of an event which includes invalid mentions."""
133134
bulk_evaluator = BulkPushRuleEvaluator(self.hs)

0 commit comments

Comments
 (0)