From a55e2707d73c19b555c18ebc19df3170a96055e2 Mon Sep 17 00:00:00 2001 From: Brendan Abolivier Date: Mon, 7 Sep 2020 15:15:06 +0100 Subject: [PATCH] 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`. --- changelog.d/8270.feature | 1 + synapse/storage/databases/main/event_push_actions.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 changelog.d/8270.feature diff --git a/changelog.d/8270.feature b/changelog.d/8270.feature new file mode 100644 index 000000000..feb02be23 --- /dev/null +++ b/changelog.d/8270.feature @@ -0,0 +1 @@ +Add unread messages count to sync responses, as specified in [MSC2654](https://github.com/matrix-org/matrix-doc/pull/2654). diff --git a/synapse/storage/databases/main/event_push_actions.py b/synapse/storage/databases/main/event_push_actions.py index 001d06378..50fac9e72 100644 --- a/synapse/storage/databases/main/event_push_actions.py +++ b/synapse/storage/databases/main/event_push_actions.py @@ -177,7 +177,12 @@ class EventPushActionsWorkerStore(SQLBaseStore): if row: notif_count += row[0] - unread_count += row[1] + + if row[1] is not None: + # The unread_count column of event_push_summary is NULLable, so we need + # to make sure we don't try increasing the unread counts if it's NULL + # for this row. + unread_count += row[1] return { "notify_count": notif_count,