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

Support the backwards compatibility features in MSC3952. #14958

Merged
merged 9 commits into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions rust/src/push/evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ impl PushRuleEvaluator {
// experimental feature is enabled, both of these are represented
// by the has_mentions flag).
if self.has_mentions
&& (rule_id == ".m.rule.contains_display_name"
|| rule_id == ".m.rule.contains_user_name"
|| rule_id == ".m.rule.roomnotif")
&& (rule_id == "global/override/.m.rule.contains_display_name"
|| rule_id == "global/content/.m.rule.contains_user_name"
|| rule_id == "global/override/.m.rule.roomnotif")
DMRobertson marked this conversation as resolved.
Show resolved Hide resolved
{
continue;
}
Expand Down
24 changes: 24 additions & 0 deletions tests/push/test_bulk_push_rule_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,18 @@ def test_user_mentions(self) -> None:
)
)

# The legacy push rule should not mention if the mentions field exists.
self.assertFalse(
self._create_and_process(
bulk_evaluator,
{
"body": self.alice,
"msgtype": "m.text",
EventContentFields.MSC3952_MENTIONS: {},
},
)
)

@override_config({"experimental_features": {"msc3952_intentional_mentions": True}})
def test_room_mentions(self) -> None:
"""Test the behavior of an event which includes invalid room mentions."""
Expand Down Expand Up @@ -346,3 +358,15 @@ def test_room_mentions(self) -> None:
{EventContentFields.MSC3952_MENTIONS: {"room": mentions}},
)
)

# The legacy push rule should not mention if the mentions field exists.
self.assertFalse(
self._create_and_process(
bulk_evaluator,
{
"body": "@room",
"msgtype": "m.text",
EventContentFields.MSC3952_MENTIONS: {},
},
)
)