Skip to content

Commit

Permalink
Ignore notification counts from rooms you've left (#16954)
Browse files Browse the repository at this point in the history
Co-authored-by: reivilibre <[email protected]>
  • Loading branch information
anoadragon453 and reivilibre authored Feb 23, 2024
1 parent 8de3283 commit 274f289
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/16954.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug introduced in v1.100.0 where notifications from rooms you've left would continue to be counted.
18 changes: 15 additions & 3 deletions synapse/storage/databases/main/event_push_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,11 @@ def _get_unread_counts_by_room_for_user_txn(
SELECT e.room_id, notif_count, e.stream_ordering, e.thread_id, last_receipt_stream_ordering,
ev.stream_ordering AS receipt_stream_ordering
FROM event_push_summary AS e
INNER JOIN local_current_membership USING (user_id, room_id)
INNER JOIN local_current_membership AS lcm ON (
e.user_id = lcm.user_id
AND e.room_id = lcm.room_id
AND lcm.membership = 'join'
)
LEFT JOIN receipts_linearized AS r ON (
e.user_id = r.user_id
AND e.room_id = r.room_id
Expand Down Expand Up @@ -472,7 +476,11 @@ def _get_unread_counts_by_room_for_user_txn(
SELECT e.room_id, e.stream_ordering, e.thread_id,
ev.stream_ordering AS receipt_stream_ordering
FROM event_push_actions AS e
INNER JOIN local_current_membership USING (user_id, room_id)
INNER JOIN local_current_membership AS lcm ON (
e.user_id = lcm.user_id
AND e.room_id = lcm.room_id
AND lcm.membership = 'join'
)
LEFT JOIN receipts_linearized AS r ON (
e.user_id = r.user_id
AND e.room_id = r.room_id
Expand Down Expand Up @@ -514,7 +522,11 @@ def _get_unread_counts_by_room_for_user_txn(
SELECT e.room_id, e.stream_ordering, e.thread_id,
ev.stream_ordering AS receipt_stream_ordering
FROM event_push_actions AS e
INNER JOIN local_current_membership USING (user_id, room_id)
INNER JOIN local_current_membership AS lcm ON (
e.user_id = lcm.user_id
AND e.room_id = lcm.room_id
AND lcm.membership = 'join'
)
LEFT JOIN receipts_linearized AS r ON (
e.user_id = r.user_id
AND e.room_id = r.room_id
Expand Down

0 comments on commit 274f289

Please sign in to comment.