From 1836d8958e2ee8ab9fc98901d90c0a8c2941e411 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Sun, 15 Sep 2013 14:49:04 -0400 Subject: [PATCH] Add comment about sending presence updates (imported from commit da9c521a6ad652e4dbcaabcc3a24b3e23376f545) --- zerver/lib/actions.py | 9 ++++++++- zerver/lib/cache.py | 4 +--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index 2456afd65f..5b16413822 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -1085,7 +1085,14 @@ def do_update_user_presence(user_profile, client, log_time, status): if not user_profile.realm.domain == "mit.edu" and (created or became_online): # Push event to all users in the realm so they see the new user # appear in the presence list immediately, or the newly online - # user without delay + # user without delay. Note that we won't send an update here for a + # timestamp update, because we rely on the browser to ping us every 50 + # seconds for realm-wide status updates, and those updates should have + # recent timestamps, which means the browser won't think active users + # have gone idle. If we were more aggressive in this function about + # sending timestamp updates, we could eliminate the ping responses, but + # that's not a high priority for now, considering that most of our non-MIT + # realms are pretty small. send_presence_changed(user_profile, presence) def update_user_activity_interval(user_profile, log_time): diff --git a/zerver/lib/cache.py b/zerver/lib/cache.py index eb0dbe84cf..2a3baa86b8 100644 --- a/zerver/lib/cache.py +++ b/zerver/lib/cache.py @@ -260,9 +260,7 @@ def update_user_presence_cache(sender, **kwargs): # For any status update, flush the user's realm's entry in the # UserPresence cache to avoid giving out stale state. Since we # get a lot of presence updates, we are likely to get cache misses - # when new messages come in, but the query is pretty quick, and we - # no longer have the issue of Tornado needing to go the cache or DB - # to get presence info. + # when new messages come in, but the query is pretty quick. user_profile = kwargs['instance'].user_profile djcache.delete(KEY_PREFIX + status_dict_cache_key(user_profile))