summary refs log tree commit diff
path: root/synapse/push/push_tools.py
diff options
context:
space:
mode:
authorBrendan Abolivier <babolivier@matrix.org>2020-07-29 18:26:55 +0100
committerGitHub <noreply@github.com>2020-07-29 18:26:55 +0100
commit8dff4a12424cda9e4abaa5f2905d58aa6e723777 (patch)
treeed7a3fde822301d9cd82ce22eb56e53ae40b5c32 /synapse/push/push_tools.py
parentVarious improvements to the docs (#7899) (diff)
downloadsynapse-8dff4a12424cda9e4abaa5f2905d58aa6e723777.tar.xz
Re-implement unread counts (#7736)
Diffstat (limited to 'synapse/push/push_tools.py')
-rw-r--r--synapse/push/push_tools.py17
1 files changed, 4 insertions, 13 deletions
diff --git a/synapse/push/push_tools.py b/synapse/push/push_tools.py
index d0145666bf..bc8f71916b 100644
--- a/synapse/push/push_tools.py
+++ b/synapse/push/push_tools.py
@@ -21,22 +21,13 @@ async def get_badge_count(store, user_id):
     invites = await store.get_invited_rooms_for_local_user(user_id)
     joins = await store.get_rooms_for_user(user_id)
 
-    my_receipts_by_room = await store.get_receipts_for_user(user_id, "m.read")
-
     badge = len(invites)
 
     for room_id in joins:
-        if room_id in my_receipts_by_room:
-            last_unread_event_id = my_receipts_by_room[room_id]
-
-            notifs = await (
-                store.get_unread_event_push_actions_by_room_for_user(
-                    room_id, user_id, last_unread_event_id
-                )
-            )
-            # return one badge count per conversation, as count per
-            # message is so noisy as to be almost useless
-            badge += 1 if notifs["notify_count"] else 0
+        unread_count = await store.get_unread_message_count_for_user(room_id, user_id)
+        # return one badge count per conversation, as count per
+        # message is so noisy as to be almost useless
+        badge += 1 if unread_count else 0
     return badge