diff options
author | Erik Johnston <erikj@jki.re> | 2017-03-15 17:37:15 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-15 17:37:15 +0000 |
commit | 54d2b7e596ffe330b8354d6ca78ee6ca6b7e6484 (patch) | |
tree | 922a54caf1885a43c2229fcd8a1ea66044a2d5e9 | |
parent | Merge pull request #2013 from matrix-org/erikj/presence_FASTER (diff) | |
parent | Modify test_user_sync so it doesn't look at last_active_ts over last_user_syn... (diff) | |
download | synapse-54d2b7e596ffe330b8354d6ca78ee6ca6b7e6484.tar.xz |
Merge pull request #2014 from Half-Shot/hs/fix-appservice-presence
Add fallback to last_active_ts if it beats the last sync time on a presence timeout.
Diffstat (limited to '')
-rw-r--r-- | synapse/handlers/presence.py | 5 | ||||
-rw-r--r-- | tests/handlers/test_presence.py | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py index 9cc94287b3..e562a2e87a 100644 --- a/synapse/handlers/presence.py +++ b/synapse/handlers/presence.py @@ -1174,7 +1174,10 @@ 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: + # 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( state=PresenceState.OFFLINE, status_msg=None, diff --git a/tests/handlers/test_presence.py b/tests/handlers/test_presence.py index d9e8f634ae..de06a6ad30 100644 --- a/tests/handlers/test_presence.py +++ b/tests/handlers/test_presence.py @@ -324,7 +324,7 @@ class PresenceTimeoutTestCase(unittest.TestCase): state = UserPresenceState.default(user_id) state = state.copy_and_replace( state=PresenceState.ONLINE, - last_active_ts=now, + last_active_ts=0, last_user_sync_ts=now - SYNC_ONLINE_TIMEOUT - 1, ) |