mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-14 20:15:24 -04:00
Update intentional mentions (MSC3952) to depend on exact_event_property_contains
(MSC3966). (#15051)
This replaces the specific `is_user_mention` push rule condition used in MSC3952 with the generic `exact_event_property_contains` push rule condition from MSC3966.
This commit is contained in:
parent
33a85cf08c
commit
8ef324ea6f
11 changed files with 73 additions and 94 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue