Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
53 lines
1.5 KiB
Markdown
53 lines
1.5 KiB
Markdown
# Unread message synchronization
|
|
|
|
In general displaying unread counts for all channels and topics may require
|
|
downloading an unbounded number of messages. Consider a user who has a muted
|
|
channel or topic and has not read the backlog in a month; to have an accurate
|
|
unread count we would need to load all messages this user has received in the
|
|
past month. This is inefficient for web clients and even more for mobile
|
|
devices.
|
|
|
|
We work around this by including a list of unread message ids in the initial
|
|
state grouped by relevant conversation keys. This data is included in the
|
|
`unread_msgs` key if both `update_message_flags` and `message` are required
|
|
in the register call.
|
|
|
|
```json
|
|
{
|
|
"count": 4,
|
|
"huddles": [
|
|
{
|
|
"user_ids_string": "3,4,6",
|
|
"unread_message_ids": [
|
|
34
|
|
]
|
|
}
|
|
],
|
|
"streams": [
|
|
{
|
|
"stream_id": 1,
|
|
"topic": "test",
|
|
"unread_message_ids": [
|
|
33
|
|
]
|
|
}
|
|
],
|
|
"pms": [
|
|
{
|
|
"sender_id": 3,
|
|
"unread_message_ids": [
|
|
31,
|
|
32
|
|
]
|
|
}
|
|
],
|
|
"mentions": [31, 34]
|
|
}
|
|
```
|
|
|
|
Three event types are required to correctly maintain the `unread_msgs`. New
|
|
messages can be created without the unread flag by the `message` event type.
|
|
The unread flag can be added and removed by the `update_message_flags` event,
|
|
and the topic of unread messages can be updated by the `update_message` event
|
|
type.
|