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

Commit a55e270

Browse files
authored
Fix unread count failing on NULL values (#8270)
Fix unread counts making sync fail if the value of the `unread_count` column in `event_push_summary` is `None`.
1 parent 0dae7d8 commit a55e270

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

changelog.d/8270.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add unread messages count to sync responses, as specified in [MSC2654](https://github.com/matrix-org/matrix-doc/pull/2654).

synapse/storage/databases/main/event_push_actions.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,12 @@ def _get_unread_counts_by_pos_txn(self, txn, room_id, user_id, stream_ordering):
177177

178178
if row:
179179
notif_count += row[0]
180-
unread_count += row[1]
180+
181+
if row[1] is not None:
182+
# The unread_count column of event_push_summary is NULLable, so we need
183+
# to make sure we don't try increasing the unread counts if it's NULL
184+
# for this row.
185+
unread_count += row[1]
181186

182187
return {
183188
"notify_count": notif_count,

0 commit comments

Comments
 (0)