Skip to content

Commit ff4dbe1

Browse files
committed
Merge branch 'count-reactions-as-unread' into 'master'
DES-735: Count reactions as unread if room has less than 20 members See merge request beeper/synapse!12
2 parents bf82012 + 98dbb27 commit ff4dbe1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

synapse/push/bulk_push_rule_evaluator.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from synapse.events import EventBase
2525
from synapse.events.snapshot import EventContext
2626
from synapse.state import POWER_KEY
27+
from synapse.storage.roommember import ProfileInfo
2728
from synapse.util.async_helpers import Linearizer
2829
from synapse.util.caches import CacheMetric, register_cache
2930
from synapse.util.caches.descriptors import lru_cache
@@ -54,7 +55,9 @@
5455
)
5556

5657

57-
def _should_count_as_unread(event: EventBase, context: EventContext) -> bool:
58+
def _should_count_as_unread(
59+
event: EventBase, context: EventContext, room_members: Dict[str, ProfileInfo]
60+
) -> bool:
5861
# Exclude rejected and soft-failed events.
5962
if context.rejected or event.internal_metadata.is_soft_failed():
6063
return False
@@ -71,6 +74,8 @@ def _should_count_as_unread(event: EventBase, context: EventContext) -> bool:
7174
elif event.type == EventTypes.Message:
7275
body = event.content.get("body")
7376
return isinstance(body, str) and bool(body)
77+
elif event.type == "m.reaction":
78+
return len(room_members) < 20
7479

7580
return False
7681

@@ -170,13 +175,13 @@ async def action_for_event_by_user(
170175
should increment the unread count, and insert the results into the
171176
event_push_actions_staging table.
172177
"""
173-
count_as_unread = _should_count_as_unread(event, context)
174-
175178
rules_by_user = await self._get_rules_for_event(event, context)
176179
actions_by_user: Dict[str, List[Union[dict, str]]] = {}
177180

178181
room_members = await self.store.get_joined_users_from_context(event, context)
179182

183+
count_as_unread = _should_count_as_unread(event, context, room_members)
184+
180185
(
181186
power_levels,
182187
sender_power_level,

0 commit comments

Comments
 (0)