element-hq / element-hq/synapse
`notifier.wait_for_events(user_id)` should notify when `device_one_time_keys_count` changes
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 600
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 51
Description
*Spawning from a [discussion on a Sliding Sync PR](https://github.com/element-hq/synapse/pull/17454#discussion_r1686971163),*
---
`notifier.wait_for_events(user_id)` is [used in Sync v2](https://github.com/element-hq/synapse/blob/e8ee784c75d161d1634a60b7c4e419e8f08273b8/synapse/handlers/sync.py#L582-L595) and [Sliding Sync](https://github.com/element-hq/synapse/blob/e8ee784c75d161d1634a60b7c4e419e8f08273b8/synapse/handlers/sliding_sync.py#L420-L435) to to wait for something to happen before assembling a sync response.
It currently [handles things](https://github.com/element-hq/synapse/blob/e8ee784c75d161d1634a60b7c4e419e8f08273b8/synapse/notifier.py#L466-L506) like new events, account data, to-device messages, typing activity, etc but doesn't pick up when your device one-time-key (OTK) counts change which affects the `device_one_time_keys_count`/`device_unused_fallback_key_types` in the sync response and should be considered new activity.
Currently, if other devices exhaust your OTKs without other activity to notify your sync loop, you would never be notified to upload more.
Contributor guide
Research direction
Start in synapse/notifier.py at the wait_for_events handling around lines 466-506, then read its callers in synapse/handlers/sync.py and synapse/handlers/sliding_sync.py. Trace how device_one_time_keys_count and device_unused_fallback_key_types enter the sync response. Done means OTK count changes wake the relevant sync loop even without other activity, with coverage for that notification path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100