2424from synapse .events import EventBase
2525from synapse .events .snapshot import EventContext
2626from synapse .state import POWER_KEY
27+ from synapse .storage .roommember import ProfileInfo
2728from synapse .util .async_helpers import Linearizer
2829from synapse .util .caches import CacheMetric , register_cache
2930from synapse .util .caches .descriptors import lru_cache
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