From f0eb495ceebfced779d54b5fcfab2aabdea35ad2 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 6 Jun 2019 15:41:28 -0600 Subject: [PATCH 1/2] Clarify how notification counts are calculated in /sync Fixes https://github.com/matrix-org/matrix-doc/issues/2015 --- api/client-server/sync.yaml | 6 ++++-- changelogs/client_server/newsfragments/2097.clarification | 1 + specification/modules/receipts.rst | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 changelogs/client_server/newsfragments/2097.clarification diff --git a/api/client-server/sync.yaml b/api/client-server/sync.yaml index 02fddb84..4514d417 100644 --- a/api/client-server/sync.yaml +++ b/api/client-server/sync.yaml @@ -167,11 +167,13 @@ paths: this room. allOf: - $ref: "definitions/event_batch.yaml" - "unread_notifications": + unread_notifications: title: Unread Notification Counts type: object description: |- - Counts of unread notifications for this room + Counts of unread notifications for this room. See the + `Receipts module <#module-receipts>`_ for more information + on how these are calculated. properties: highlight_count: title: Highlighted notification count diff --git a/changelogs/client_server/newsfragments/2097.clarification b/changelogs/client_server/newsfragments/2097.clarification new file mode 100644 index 00000000..68d89bcc --- /dev/null +++ b/changelogs/client_server/newsfragments/2097.clarification @@ -0,0 +1 @@ +Clarify how ``unread_notifications`` is calculated. diff --git a/specification/modules/receipts.rst b/specification/modules/receipts.rst index ee2b697a..1745706e 100644 --- a/specification/modules/receipts.rst +++ b/specification/modules/receipts.rst @@ -26,7 +26,9 @@ to a homeserver. To prevent this from becoming a problem, receipts are implement using "up to" markers. This marker indicates that the acknowledgement applies to all events "up to and including" the event specified. For example, marking an event as "read" would indicate that the user had read all events *up to* the -referenced event. +referenced event. Servers MUST decremement the number of pending notifications +for a user if the events are up to or including the read receipt. This is typically +done by adjusting the ``unread_notifications`` value in a ``/sync`` response. Events ------ From 1886a2346a27579cd378b4f112181d880626b460 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 10 Jun 2019 13:38:43 -0600 Subject: [PATCH 2/2] Move explanation of notifications to notifications module --- api/client-server/sync.yaml | 4 ++-- specification/modules/push.rst | 11 +++++++++++ specification/modules/receipts.rst | 5 ++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/api/client-server/sync.yaml b/api/client-server/sync.yaml index 4514d417..89292673 100644 --- a/api/client-server/sync.yaml +++ b/api/client-server/sync.yaml @@ -172,8 +172,8 @@ paths: type: object description: |- Counts of unread notifications for this room. See the - `Receipts module <#module-receipts>`_ for more information - on how these are calculated. + `Receiving notifications section <#receiving-notifications>`_ + for more information on how these are calculated. properties: highlight_count: title: Highlighted notification count diff --git a/specification/modules/push.rst b/specification/modules/push.rst index 1bac0c2e..33ca7fd7 100644 --- a/specification/modules/push.rst +++ b/specification/modules/push.rst @@ -1,4 +1,5 @@ .. Copyright 2016 OpenMarket Ltd +.. Copyright 2019 The Matrix.org Foundation C.I.C. .. .. Licensed under the Apache License, Version 2.0 (the "License"); .. you may not use this file except in compliance with the License. @@ -116,6 +117,16 @@ have received. {{notifications_cs_http_api}} +Receiving notifications +~~~~~~~~~~~~~~~~~~~~~~~ + +Servers MUST include the number of unread notifications in a client's ``/sync`` +stream, and MUST update it as it changes. Notifications are determined by the +push rules which apply to an event. + +When the user updates their read receipt (either by using the API or by sending an +event), notifications prior to and including that event MUST be marked as read. + Push Rules ~~~~~~~~~~ A push rule is a single rule that states under what *conditions* an event should diff --git a/specification/modules/receipts.rst b/specification/modules/receipts.rst index 1745706e..4630091f 100644 --- a/specification/modules/receipts.rst +++ b/specification/modules/receipts.rst @@ -26,9 +26,8 @@ to a homeserver. To prevent this from becoming a problem, receipts are implement using "up to" markers. This marker indicates that the acknowledgement applies to all events "up to and including" the event specified. For example, marking an event as "read" would indicate that the user had read all events *up to* the -referenced event. Servers MUST decremement the number of pending notifications -for a user if the events are up to or including the read receipt. This is typically -done by adjusting the ``unread_notifications`` value in a ``/sync`` response. +referenced event. See the `Receiving notifications <#receiving-notifications>`_ +section for more information on how read receipts affect notification counts. Events ------