summary refs log tree commit diff
path: root/synapse/push/push_tools.py
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2024-03-05 11:51:18 +0000
committerAndrew Morgan <andrew@amorgan.xyz>2024-03-05 11:51:18 +0000
commit2b78ad37b3c938ec6ecd01dc5e5c1d1db35a91bd (patch)
tree0c2f2b69d5626d804e9750d1d8470ea281effa4b /synapse/push/push_tools.py
parent1.102.0rc1 (diff)
downloadsynapse-2b78ad37b3c938ec6ecd01dc5e5c1d1db35a91bd.tar.xz
Revert "Improve DB performance of calculating badge counts for push. (#16756)"
This reverts commit b11f7b5122061d4908b3328689486bc16dc58445.
Diffstat (limited to 'synapse/push/push_tools.py')
-rw-r--r--synapse/push/push_tools.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/synapse/push/push_tools.py b/synapse/push/push_tools.py

index 76c7ab6477..1ef881f702 100644 --- a/synapse/push/push_tools.py +++ b/synapse/push/push_tools.py
@@ -29,11 +29,17 @@ from synapse.storage.databases.main import DataStore async def get_badge_count(store: DataStore, user_id: str, group_by_room: bool) -> int: invites = await store.get_invited_rooms_for_local_user(user_id) + joins = await store.get_rooms_for_user(user_id) badge = len(invites) room_to_count = await store.get_unread_counts_by_room_for_user(user_id) - for _room_id, notify_count in room_to_count.items(): + for room_id, notify_count in room_to_count.items(): + # room_to_count may include rooms which the user has left, + # ignore those. + if room_id not in joins: + continue + if notify_count == 0: continue