diff --git a/synapse/push/bulk_push_rule_evaluator.py b/synapse/push/bulk_push_rule_evaluator.py
index 3c4a152d6b..abcf687f05 100644
--- a/synapse/push/bulk_push_rule_evaluator.py
+++ b/synapse/push/bulk_push_rule_evaluator.py
@@ -23,7 +23,6 @@ from typing import (
Mapping,
Optional,
Sequence,
- Set,
Tuple,
Union,
)
@@ -396,18 +395,10 @@ class BulkPushRuleEvaluator:
del notification_levels[key]
# Pull out any user and room mentions.
- mentions = event.content.get(EventContentFields.MSC3952_MENTIONS)
- has_mentions = self._intentional_mentions_enabled and isinstance(mentions, dict)
- user_mentions: Set[str] = set()
- if has_mentions:
- # mypy seems to have lost the type even though it must be a dict here.
- assert isinstance(mentions, dict)
- # Remove out any non-string items and convert to a set.
- user_mentions_raw = mentions.get("user_ids")
- if isinstance(user_mentions_raw, list):
- user_mentions = set(
- filter(lambda item: isinstance(item, str), user_mentions_raw)
- )
+ has_mentions = (
+ self._intentional_mentions_enabled
+ and EventContentFields.MSC3952_MENTIONS in event.content
+ )
evaluator = PushRuleEvaluator(
_flatten_dict(
@@ -415,7 +406,6 @@ class BulkPushRuleEvaluator:
msc3873_escape_event_match_key=self.hs.config.experimental.msc3873_escape_event_match_key,
),
has_mentions,
- user_mentions,
room_member_count,
sender_power_level,
notification_levels,
diff --git a/synapse/push/clientformat.py b/synapse/push/clientformat.py
index bb76c169c6..222afbdcc8 100644
--- a/synapse/push/clientformat.py
+++ b/synapse/push/clientformat.py
@@ -41,11 +41,12 @@ def format_push_rules_for_user(
rulearray.append(template_rule)
- pattern_type = template_rule.pop("pattern_type", None)
- if pattern_type == "user_id":
- template_rule["pattern"] = user.to_string()
- elif pattern_type == "user_localpart":
- template_rule["pattern"] = user.localpart
+ for type_key in ("pattern", "value"):
+ type_value = template_rule.pop(f"{type_key}_type", None)
+ if type_value == "user_id":
+ template_rule[type_key] = user.to_string()
+ elif type_value == "user_localpart":
+ template_rule[type_key] = user.localpart
template_rule["enabled"] = enabled
|