Send ids, not emails, of subscribers when loading the page.

(imported from commit 26bbf38664d246476df7062432fa20add7d4cb11)
This commit is contained in:
Steve Howell 2013-10-21 13:37:52 -04:00
parent 3b59952ea3
commit db398d5e41
3 changed files with 23 additions and 3 deletions

View File

@ -637,8 +637,26 @@ exports.invite_user_to_stream = function (user_email, stream_name, success, fail
}); });
}; };
function inline_emails_into_subscriber_list(subs, email_dict) {
// When we get subscriber lists from the back end, they are sent as user ids to
// save bandwidth, but the legacy JS code wants emails.
_.each(subs, function (sub) {
if (sub.subscribers) {
sub.subscribers = _.map(sub.subscribers, function (subscription) {
return email_dict[subscription];
});
}
});
}
$(function () { $(function () {
var i; var i;
inline_emails_into_subscriber_list(page_params.stream_list, page_params.email_dict);
inline_emails_into_subscriber_list(page_params.unsubbed_info, page_params.email_dict);
// Populate stream_info with data handed over to client-side template. // Populate stream_info with data handed over to client-side template.
populate_subscriptions(page_params.stream_list, true); populate_subscriptions(page_params.stream_list, true);
populate_subscriptions(page_params.unsubbed_info, false); populate_subscriptions(page_params.unsubbed_info, false);

View File

@ -1626,9 +1626,10 @@ def do_events_register(user_profile, user_client, apply_markdown=True,
ret['onboarding_steps'] = [{'email' : profile.email, ret['onboarding_steps'] = [{'email' : profile.email,
'steps' : profile.onboarding_steps}] 'steps' : profile.onboarding_steps}]
if event_types is None or "subscription" in event_types: if event_types is None or "subscription" in event_types:
subs = gather_subscriptions(user_profile) subscriptions, unsubscribed, email_dict = gather_subscriptions_helper(user_profile)
ret['subscriptions'] = subs[0] ret['subscriptions'] = subscriptions
ret['unsubscribed'] = subs[1] ret['unsubscribed'] = unsubscribed
ret['email_dict'] = email_dict
if event_types is None or "presence" in event_types: if event_types is None or "presence" in event_types:
ret['presences'] = get_status_dict(user_profile) ret['presences'] = get_status_dict(user_profile)
if event_types is None or "referral" in event_types: if event_types is None or "referral" in event_types:

View File

@ -708,6 +708,7 @@ def home(request):
have_initial_messages = user_has_messages, have_initial_messages = user_has_messages,
stream_list = register_ret['subscriptions'], stream_list = register_ret['subscriptions'],
unsubbed_info = register_ret['unsubscribed'], unsubbed_info = register_ret['unsubscribed'],
email_dict = register_ret['email_dict'],
people_list = register_ret['realm_users'], people_list = register_ret['realm_users'],
initial_pointer = register_ret['pointer'], initial_pointer = register_ret['pointer'],
initial_presences = register_ret['presences'], initial_presences = register_ret['presences'],