Suppress presence changes to IDLE until timeout

This way if two browsers are disagreeing about your active status, the
active one wins. The active browser continues to update your timestamp,
and the idle browser's changes are discarded until the timestamp on your
active status expires.

(imported from commit dc29e013d045c4b72793097f611ba6802c58e57a)
This commit is contained in:
Luke Faraone 2014-03-17 13:35:43 -04:00
parent 286bd3005d
commit e6bb683922
1 changed files with 7 additions and 1 deletions

View File

@ -1788,7 +1788,13 @@ def do_update_user_presence(user_profile, client, log_time, status):
was_idle = presence.status == UserPresence.IDLE
became_online = (status == UserPresence.ACTIVE) and (stale_status or was_idle)
if not created:
# If an object was created, it has already been saved.
#
# We suppress changes from ACTIVE to IDLE before stale_status is reached;
# this protects us from the user having two clients open: one active, the
# other idle. Without this check, we would constantly toggle their status
# between the two states.
if not created and stale_status or was_idle or status == presence.status:
# The following block attempts to only update the "status"
# field in the event that it actually changed. This is
# important to avoid flushing the UserPresence cache when the