diff --git a/static/js/feature_flags.js b/static/js/feature_flags.js index 738e7b04af..a174eeff8b 100644 --- a/static/js/feature_flags.js +++ b/static/js/feature_flags.js @@ -7,6 +7,7 @@ exports.summarize_read_while_narrowed = page_params.staging; exports.twenty_four_hour_time = _.contains([], page_params.email); exports.dropbox_integration = page_params.staging || _.contains(['dropbox.com'], page_params.domain); +exports.email_forwarding = page_params.staging; return exports; }()); diff --git a/static/js/subs.js b/static/js/subs.js index 41eeb24c5c..09a937b726 100644 --- a/static/js/subs.js +++ b/static/js/subs.js @@ -210,8 +210,9 @@ exports.show_settings_for = function (stream_name) { }; function add_sub_to_table(sub) { - $('#create_stream_row').after( - templates.render('subscription', sub)); + $('#create_stream_row').after(templates.render( + 'subscription', + _.extend(sub, {'show_email_token': feature_flags.email_forwarding}))); settings_for_sub(sub).collapse('show'); } @@ -363,7 +364,8 @@ function populate_subscriptions(subs, subscribed) { var stream_name = elem.name; var sub = create_sub(stream_name, {color: elem.color, in_home_view: elem.in_home_view, invite_only: elem.invite_only, - notifications: elem.notifications, subscribed: subscribed}); + notifications: elem.notifications, subscribed: subscribed, + email_address: elem.email_address}); sub_rows.push(sub); }); @@ -432,6 +434,9 @@ exports.setup_page = function () { if (!sub) { sub = create_sub(stream, {subscribed: false}); } + if (feature_flags.email_forwarding) { + sub = _.extend(sub, {'show_email_token': feature_flags.email_forwarding}); + } sub_rows.push(sub); }); diff --git a/static/templates/subscription.handlebars b/static/templates/subscription.handlebars index 25b7f08f87..53893ad3bf 100644 --- a/static/templates/subscription.handlebars +++ b/static/templates/subscription.handlebars @@ -44,6 +44,11 @@ + {{#if_and show_email_token subscribed}} +
+

Email address: {{email_address}}

+
+ {{/if_and}} {{#render_subscribers}}
Members diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index 726ed20130..45fc80372c 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -550,7 +550,8 @@ def notify_subscriptions_added(user_profile, sub_pairs, no_log=False): payload = [dict(name=stream.name, in_home_view=subscription.in_home_view, invite_only=stream.invite_only, - color=subscription.color) + color=subscription.color, + email_address=encode_email_address(stream)) for (subscription, stream) in sub_pairs] notice = dict(event=dict(type="subscriptions", op="add", subscriptions=payload), @@ -1070,18 +1071,19 @@ def gather_subscriptions(user_profile): stream_hash = {} for stream in Stream.objects.filter(id__in=stream_ids): - stream_hash[stream.id] = (stream.name, stream.invite_only) + stream_hash[stream.id] = stream subscribed = [] unsubscribed = [] for sub in subs: - (stream_name, invite_only) = stream_hash[sub.recipient.type_id] - stream = {'name': stream_name, + stream = stream_hash[sub.recipient.type_id] + stream = {'name': stream.name, 'in_home_view': sub.in_home_view, - 'invite_only': invite_only, + 'invite_only': stream.invite_only, 'color': sub.color, - 'notifications': sub.notifications} + 'notifications': sub.notifications, + 'email_address': encode_email_address(stream)} if sub.active: subscribed.append(stream) else: diff --git a/zerver/tests.py b/zerver/tests.py index bdc74d963d..ffee0d23ba 100644 --- a/zerver/tests.py +++ b/zerver/tests.py @@ -872,6 +872,7 @@ class SubscriptionPropertiesTest(AuthedTestCase): stream_name = sub['name'] old_color = sub['color'] invite_only = sub['invite_only'] + email_address = sub['email_address'] new_color = "#ffffff" # TODO: ensure that this is different from old_color result = self.client.post("/json/subscriptions/property", {"property": "color", @@ -882,7 +883,8 @@ class SubscriptionPropertiesTest(AuthedTestCase): new_subs = gather_subscriptions(get_user_profile_by_email(test_email))[0] sub = {'name': stream_name, 'in_home_view': True, 'color': new_color, - 'invite_only': invite_only, 'notifications': False} + 'invite_only': invite_only, 'notifications': False, + 'email_address': email_address} self.assertIn(sub, new_subs) new_subs.remove(sub)