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

Commit

Permalink
Remove offline devices.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Aug 23, 2023
1 parent a55a198 commit b133625
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion synapse/handlers/presence.py
Expand Up @@ -2053,6 +2053,7 @@ def handle_timeout(
# Check per-device whether the device should be considered idle or offline
# due to timeouts.
device_changed = False
offline_devices = []
for device_id, device_state in user_devices.items():
if device_state.state == PresenceState.ONLINE:
if now - device_state.last_active_ts > IDLE_TIMER:
Expand All @@ -2072,9 +2073,13 @@ def handle_timeout(

if now - sync_or_active > SYNC_ONLINE_TIMEOUT:
# Mark the device as going offline.
device_state.state = PresenceState.OFFLINE
offline_devices.append(device_id)
device_changed = True

# Offline devices are not needed and do not add information.
for device_id in offline_devices:
user_devices.pop(device_id)

# If the presence state of the devices changed, then (maybe) update
# the user's overall presence state.
if device_changed:
Expand Down

0 comments on commit b133625

Please sign in to comment.