Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit b133625

Browse files
committed
Remove offline devices.
1 parent a55a198 commit b133625

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

synapse/handlers/presence.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2053,6 +2053,7 @@ def handle_timeout(
20532053
# Check per-device whether the device should be considered idle or offline
20542054
# due to timeouts.
20552055
device_changed = False
2056+
offline_devices = []
20562057
for device_id, device_state in user_devices.items():
20572058
if device_state.state == PresenceState.ONLINE:
20582059
if now - device_state.last_active_ts > IDLE_TIMER:
@@ -2072,9 +2073,13 @@ def handle_timeout(
20722073

20732074
if now - sync_or_active > SYNC_ONLINE_TIMEOUT:
20742075
# Mark the device as going offline.
2075-
device_state.state = PresenceState.OFFLINE
2076+
offline_devices.append(device_id)
20762077
device_changed = True
20772078

2079+
# Offline devices are not needed and do not add information.
2080+
for device_id in offline_devices:
2081+
user_devices.pop(device_id)
2082+
20782083
# If the presence state of the devices changed, then (maybe) update
20792084
# the user's overall presence state.
20802085
if device_changed:

0 commit comments

Comments
 (0)