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

Commit 3c88356

Browse files
committed
Add an experimental config option.
1 parent bc3f892 commit 3c88356

File tree

6 files changed

+17
-1
lines changed

6 files changed

+17
-1
lines changed

rust/src/push/evaluator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ fn test_requires_room_version_supports_condition() {
498498
};
499499
let rules = PushRules::new(vec![custom_rule]);
500500
result = evaluator.run(
501-
&FilteredPushRules::py_new(rules, BTreeMap::new(), true, false, true),
501+
&FilteredPushRules::py_new(rules, BTreeMap::new(), true, false, true, false),
502502
None,
503503
None,
504504
);

rust/src/push/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ pub struct FilteredPushRules {
418418
msc1767_enabled: bool,
419419
msc3381_polls_enabled: bool,
420420
msc3664_enabled: bool,
421+
msc3952_intentional_mentions: bool,
421422
}
422423

423424
#[pymethods]
@@ -429,13 +430,15 @@ impl FilteredPushRules {
429430
msc1767_enabled: bool,
430431
msc3381_polls_enabled: bool,
431432
msc3664_enabled: bool,
433+
msc3952_intentional_mentions: bool,
432434
) -> Self {
433435
Self {
434436
push_rules,
435437
enabled_map,
436438
msc1767_enabled,
437439
msc3381_polls_enabled,
438440
msc3664_enabled,
441+
msc3952_intentional_mentions,
439442
}
440443
}
441444

@@ -469,6 +472,11 @@ impl FilteredPushRules {
469472
return false;
470473
}
471474

475+
if !self.msc3952_intentional_mentions && rule.rule_id.contains("org.matrix.msc3952")
476+
{
477+
return false;
478+
}
479+
472480
true
473481
})
474482
.map(|r| {

stubs/synapse/synapse_rust/push.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class FilteredPushRules:
4646
msc1767_enabled: bool,
4747
msc3381_polls_enabled: bool,
4848
msc3664_enabled: bool,
49+
msc3952_intentional_mentions: bool,
4950
): ...
5051
def rules(self) -> Collection[Tuple[PushRule, bool]]: ...
5152

synapse/config/experimental.py

+5
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,8 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:
168168

169169
# MSC3925: do not replace events with their edits
170170
self.msc3925_inhibit_edit = experimental.get("msc3925_inhibit_edit", False)
171+
172+
# MSC3952: Intentional mentions
173+
self.msc3952_intentional_mentions = experimental.get(
174+
"msc3952_intentional_mentions", False
175+
)

synapse/storage/databases/main/push_rule.py

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def _load_rules(
8989
msc1767_enabled=experimental_config.msc1767_enabled,
9090
msc3664_enabled=experimental_config.msc3664_enabled,
9191
msc3381_polls_enabled=experimental_config.msc3381_polls_enabled,
92+
msc3952_intentional_mentions=experimental_config.msc3952_intentional_mentions,
9293
)
9394

9495
return filtered_rules

tests/push/test_bulk_push_rule_evaluator.py

+1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ def test_action_for_event_by_user_disabled_by_config(self) -> None:
129129
self.get_success(bulk_evaluator.action_for_events_by_user([(event, context)]))
130130
bulk_evaluator._action_for_event_by_user.assert_not_called()
131131

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

0 commit comments

Comments
 (0)