Disable calculating unread counts unless the config flag is enabled. (#13694)

This avoids doing work that will never be used (since the
resulting unread counts will never be sent in a /sync
response).

The negative of doing this is that unread counts will be
incorrect when the feature is initially enabled.
This commit is contained in:
Patrick Cloke 2022-09-01 12:52:03 -04:00 committed by GitHub
parent f48f4dd59e
commit 390b7ce946
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 23 deletions

View file

@ -262,7 +262,12 @@ class BulkPushRuleEvaluator:
# This can happen due to out of band memberships
return
count_as_unread = _should_count_as_unread(event, context)
# Disable counting as unread unless the experimental configuration is
# enabled, as it can cause additional (unwanted) rows to be added to the
# event_push_actions table.
count_as_unread = False
if self.hs.config.experimental.msc2654_enabled:
count_as_unread = _should_count_as_unread(event, context)
rules_by_user = await self._get_rules_for_event(event)
actions_by_user: Dict[str, Collection[Union[Mapping, str]]] = {}