Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 58c1956

Browse files
committed
Fix notification count after a highlighted message
Fixes #13196 Broke by #13005
1 parent a962c5a commit 58c1956

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

synapse/storage/databases/main/event_push_actions.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,9 +1016,14 @@ def _rotate_notifs_before_txn(
10161016
upd.stream_ordering
10171017
FROM (
10181018
SELECT user_id, room_id, count(*) as cnt,
1019-
max(stream_ordering) as stream_ordering
1020-
FROM event_push_actions
1021-
WHERE ? < stream_ordering AND stream_ordering <= ?
1019+
max(ea.stream_ordering) as stream_ordering
1020+
FROM event_push_actions AS ea
1021+
LEFT JOIN event_push_summary AS old USING (user_id, room_id)
1022+
WHERE ? < ea.stream_ordering AND ea.stream_ordering <= ?
1023+
AND (
1024+
old.last_receipt_stream_ordering IS NULL
1025+
OR old.last_receipt_stream_ordering < ea.stream_ordering
1026+
)
10221027
AND %s = 1
10231028
GROUP BY user_id, room_id
10241029
) AS upd

tests/storage/test_event_push_actions.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,13 @@ def _mark_read(stream: int, depth: int) -> None:
196196
_mark_read(10, 10)
197197
_assert_counts(0, 0)
198198

199+
_inject_actions(11, HIGHLIGHT)
200+
_assert_counts(1, 1)
201+
_mark_read(11, 11)
202+
_assert_counts(0, 0)
203+
_rotate(11)
204+
_assert_counts(0, 0)
205+
199206
def test_find_first_stream_ordering_after_ts(self) -> None:
200207
def add_event(so: int, ts: int) -> None:
201208
self.get_success(

0 commit comments

Comments
 (0)