From ebf5a6b14c9a8f4d82969600ddbbc89d9bb8d935 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Wed, 15 Mar 2017 15:17:16 +0000 Subject: Add fallback to last_active_ts if it beats the last sync time. --- synapse/handlers/presence.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'synapse') diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py index da610e430f..7bd6f7d1e4 100644 --- a/synapse/handlers/presence.py +++ b/synapse/handlers/presence.py @@ -1157,7 +1157,8 @@ def handle_timeout(state, is_mine, syncing_user_ids, now): # If there are have been no sync for a while (and none ongoing), # set presence to offline if user_id not in syncing_user_ids: - if now - state.last_user_sync_ts > SYNC_ONLINE_TIMEOUT: + sync_or_active = max(state.last_user_sync_ts, state.last_active_ts) + if now - sync_or_active > SYNC_ONLINE_TIMEOUT: state = state.copy_and_replace( state=PresenceState.OFFLINE, status_msg=None, -- cgit 1.4.1 From e6032054bf2d449055d88916b89e574ce997745d Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Wed, 15 Mar 2017 15:24:48 +0000 Subject: Add a great comment to handle_timeout for active vs sync times. --- synapse/handlers/presence.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'synapse') diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py index 7bd6f7d1e4..6b35312127 100644 --- a/synapse/handlers/presence.py +++ b/synapse/handlers/presence.py @@ -1157,6 +1157,8 @@ def handle_timeout(state, is_mine, syncing_user_ids, now): # If there are have been no sync for a while (and none ongoing), # set presence to offline if user_id not in syncing_user_ids: + # If the user has done something recently but hasn't synced, + # don't set them as offline. sync_or_active = max(state.last_user_sync_ts, state.last_active_ts) if now - sync_or_active > SYNC_ONLINE_TIMEOUT: state = state.copy_and_replace( -- cgit 1.4.1