From 850519b314957017d1f6e92ee4e7382a90c0600a Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 16 May 2017 20:23:13 -0700 Subject: [PATCH] api: Move cross_realm_bots into the register_ret response. This is probably not the right long-term solution to the cross-realm bots problem (that solution is probably to eliminate cross-realm bots and replace them with per-realm bots). But in the short term, this will at least make it possible for mobile apps to interact with these cross-realm bots using the `realm_user` data set. --- zerver/lib/events.py | 3 ++- zerver/views/home.py | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/zerver/lib/events.py b/zerver/lib/events.py index 085d4ec620..c7d89d180c 100644 --- a/zerver/lib/events.py +++ b/zerver/lib/events.py @@ -26,7 +26,7 @@ from zerver.lib.realm_icon import realm_icon_url from zerver.lib.request import JsonableError from zerver.lib.actions import validate_user_access_to_subscribers_helper, \ do_get_streams, get_default_streams_for_realm, \ - gather_subscriptions_helper, \ + gather_subscriptions_helper, get_cross_realm_dicts, \ get_status_dict, streams_to_dicts_sorted from zerver.tornado.event_queue import request_event_queue, get_user_events from zerver.models import Client, Message, Realm, UserPresence, UserProfile, \ @@ -131,6 +131,7 @@ def fetch_initial_state_data(user_profile, event_types, queue_id, state['avatar_url_medium'] = avatar_url(user_profile, medium=True) state['avatar_url'] = avatar_url(user_profile) state['can_create_streams'] = user_profile.can_create_streams() + state['cross_realm_bots'] = list(get_cross_realm_dicts()) state['is_admin'] = user_profile.is_realm_admin state['user_id'] = user_profile.id state['enter_sends'] = user_profile.enter_sends diff --git a/zerver/views/home.py b/zerver/views/home.py index 536a77b67a..6e2c501d24 100644 --- a/zerver/views/home.py +++ b/zerver/views/home.py @@ -19,7 +19,7 @@ from zerver.models import Message, UserProfile, Stream, Subscription, Huddle, \ get_realm_domains from zerver.lib.events import do_events_register from zerver.lib.actions import update_user_presence, do_change_tos_version, \ - do_update_pointer, get_cross_realm_dicts, realm_user_count + do_update_pointer, realm_user_count from zerver.lib.avatar import avatar_url from zerver.lib.i18n import get_language_list, get_language_name, \ get_language_list_for_templates @@ -208,7 +208,6 @@ def home_real(request): needs_tutorial = needs_tutorial, first_in_realm = first_in_realm, prompt_for_invites = prompt_for_invites, - cross_realm_bots = list(get_cross_realm_dicts()), unread_count = approximate_unread_count(user_profile), furthest_read_time = sent_time_in_epoch_seconds(latest_read), has_mobile_devices = num_push_devices_for_user(user_profile) > 0,