Send client information for initial presence and process time differential

(imported from commit 99a51b7cc8b6c51c4e82757a984d07603b2980e3)
This commit is contained in:
Leo Franchi
2013-04-04 18:13:03 -04:00
parent 5d4b2305fe
commit 302cfcd48c
6 changed files with 68 additions and 47 deletions

View File

@@ -26,7 +26,8 @@ from zephyr.lib.actions import do_add_subscription, do_remove_subscription, \
log_subscription_property_change, internal_send_message, \
create_stream_if_needed, gather_subscriptions, subscribed_to_stream, \
update_user_presence, set_stream_color, get_stream_colors, update_message_flags, \
recipient_for_emails, extract_recipients, do_events_register, do_finish_tutorial
recipient_for_emails, extract_recipients, do_events_register, do_finish_tutorial, \
get_status_dict
from zephyr.forms import RegistrationForm, HomepageForm, ToSForm, is_unique, \
is_inactive, isnt_mit
from django.views.decorators.csrf import csrf_exempt
@@ -1459,21 +1460,8 @@ def api_beanstalk_webhook(request, user_profile, payload=POST(converter=json_to_
return json_error(ret)
return json_success()
@cache_with_key(lambda user_profile: user_profile.realm_id, timeout=60)
def get_status_list(requesting_user_profile):
user_statuses = defaultdict(dict)
# Return no status info for MIT
if requesting_user_profile.realm.domain == 'mit.edu':
return {'presences': user_statuses}
for presence in UserPresence.objects.filter(
user_profile__realm=requesting_user_profile.realm).select_related(
'user_profile', 'client'):
user_statuses[presence.user_profile.email][presence.client.name] = presence.to_dict()
return {'presences': user_statuses}
return {'presences': get_status_dict(requesting_user_profile)}
@authenticated_json_post_view
@has_request_variables