From 4ad8ad2b5a61faffd59bb0eef75684976633c6b1 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Fri, 24 Jan 2014 15:22:43 -0500 Subject: [PATCH] Extract get_realm_user_dicts() from fetch_initial_state_data(). (imported from commit 2f0f52d90eba22a4b72bd6173e60ab463482b7d6) --- zerver/lib/actions.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index a67ce44053..270aaee2d6 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -1857,6 +1857,14 @@ def get_status_dict(requesting_user_profile): return UserPresence.get_status_dict_by_realm(requesting_user_profile.realm_id) + +def get_realm_user_dicts(user_profile): + return [{'email' : userdict['email'], + 'is_bot' : userdict['is_bot'], + 'full_name' : userdict['full_name']} + for userdict in get_active_user_dicts_in_realm(user_profile.realm)] + + # Fetch initial data. When event_types is not specified, clients want # all event types. Whenever you add new code to this function, you # should also add corresponding events for changes in the data @@ -1875,10 +1883,7 @@ def fetch_initial_state_data(user_profile, event_types, queue_id): if event_types is None or "pointer" in event_types: state['pointer'] = user_profile.pointer if event_types is None or "realm_user" in event_types: - state['realm_users'] = [{'email' : userdict['email'], - 'is_bot' : userdict['is_bot'], - 'full_name' : userdict['full_name']} - for userdict in get_active_user_dicts_in_realm(user_profile.realm)] + state['realm_users'] = get_realm_user_dicts(user_profile) if event_types is None or "subscription" in event_types: subscriptions, unsubscribed, email_dict = gather_subscriptions_helper(user_profile) state['subscriptions'] = subscriptions