From 57d88632f1b590dffeeadc5b6699c276ccc85fe0 Mon Sep 17 00:00:00 2001 From: Brendan Abolivier Date: Fri, 4 Sep 2020 12:18:39 +0100 Subject: [PATCH 1/3] Fixup `ALTER TABLE` database queries Make the new columns nullable, because doing otherwise can wedge a server with a big database, as setting a default value rewrites the table. --- .../databases/main/schema/delta/58/15unread_count.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/synapse/storage/databases/main/schema/delta/58/15unread_count.sql b/synapse/storage/databases/main/schema/delta/58/15unread_count.sql index b451e8663a3c..317fba8a5dda 100644 --- a/synapse/storage/databases/main/schema/delta/58/15unread_count.sql +++ b/synapse/storage/databases/main/schema/delta/58/15unread_count.sql @@ -19,8 +19,8 @@ -- Add columns to event_push_actions and event_push_actions_staging to track unread -- messages and calculate unread counts. -ALTER TABLE event_push_actions_staging ADD COLUMN unread SMALLINT NOT NULL DEFAULT 0; -ALTER TABLE event_push_actions ADD COLUMN unread SMALLINT NOT NULL DEFAULT 0; +ALTER TABLE event_push_actions_staging ADD COLUMN unread SMALLINT; +ALTER TABLE event_push_actions ADD COLUMN unread SMALLINT; -- Add column to event_push_summary -ALTER TABLE event_push_summary ADD COLUMN unread_count BIGINT NOT NULL DEFAULT 0; \ No newline at end of file +ALTER TABLE event_push_summary ADD COLUMN unread_count BIGINT; \ No newline at end of file From e1f31bdb37c6d8e116fc3ec94ab032f0a20a1385 Mon Sep 17 00:00:00 2001 From: Brendan Abolivier Date: Fri, 4 Sep 2020 12:19:46 +0100 Subject: [PATCH 2/3] Switch back to using the notifications count in the push badge Clients are likely to be confused if we send a push but the badge count is the unread messages one, and not the notifications one. --- synapse/push/push_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/push/push_tools.py b/synapse/push/push_tools.py index f7a25571f327..d0145666bfd9 100644 --- a/synapse/push/push_tools.py +++ b/synapse/push/push_tools.py @@ -36,7 +36,7 @@ async def get_badge_count(store, user_id): ) # return one badge count per conversation, as count per # message is so noisy as to be almost useless - badge += 1 if notifs["unread_count"] else 0 + badge += 1 if notifs["notify_count"] else 0 return badge From 85f39386f8e73420632b7a67c3245345a8ea82bb Mon Sep 17 00:00:00 2001 From: Brendan Abolivier Date: Fri, 4 Sep 2020 12:21:37 +0100 Subject: [PATCH 3/3] Changelog --- changelog.d/8254.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/8254.feature diff --git a/changelog.d/8254.feature b/changelog.d/8254.feature new file mode 100644 index 000000000000..feb02be234bf --- /dev/null +++ b/changelog.d/8254.feature @@ -0,0 +1 @@ +Add unread messages count to sync responses, as specified in [MSC2654](https://github.com/matrix-org/matrix-doc/pull/2654).