element-hq / element-hq/synapse
`user_left_room` distributor signal is unreliable
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 600
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 51
Description
This issue has been migrated from [#13673](https://github.com/matrix-org/synapse/issues/13673).
---
In Synapse, there is a class called `Distributor`, which maintains a list of callbacks for a named signal and calls them all when the signal is fired: https://github.com/matrix-org/synapse/blob/develop/synapse/util/distributor.py#L43
There's only one signal defined currently and it's `user_left_room`, which is used in two places:
1. `DeviceHandler`, to mark a remote user's device list as unsubscribed
https://github.com/matrix-org/synapse/blob/1a209efdb2a6c51e52dd277de7581099852877ae/synapse/handlers/device.py#L569-L575
2. `TypingWriterHandler`, to stop a user's typing indicator when they leave a room.
https://github.com/matrix-org/synapse/blob/1a209efdb2a6c51e52dd277de7581099852877ae/synapse/handlers/typing.py#L311-L315
Unfortunately, the `user_left_room` signal is currently only reliable when local users leave a room normally (and not via a ban!).
This manifested as #13651 for device lists. Once #13651 is fixed, device list tracking will no longer use the signal.
We should look into whether the typing listener is necessary and if it can be moved elsewhere, so that we can eliminate this bit of architecture that's only used by one tiny part of synapse.
Contributor guide
Assessment
This issue has not been assessed yet.