mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 03:11:54 +00:00
create stream: Fix stream email not rendering on stream creation.
Fixes #8817
This commit is contained in:
@@ -360,6 +360,7 @@ var event_fixtures = {
|
|||||||
name: 'devel',
|
name: 'devel',
|
||||||
stream_id: 42,
|
stream_id: 42,
|
||||||
subscribers: ['alice@example.com', 'bob@example.com'],
|
subscribers: ['alice@example.com', 'bob@example.com'],
|
||||||
|
email_address: 'devel+0138515295f4@zulipdev.com:9991',
|
||||||
// etc.
|
// etc.
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -801,15 +802,21 @@ with_overrides(function (override) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var event = event_fixtures.subscription__add;
|
var event = event_fixtures.subscription__add;
|
||||||
global.with_stub(function (stub) {
|
global.with_stub(function (subscription_stub) {
|
||||||
override('stream_data.get_sub_by_id', function (stream_id) {
|
global.with_stub(function (stream_email_stub) {
|
||||||
return {stream_id: stream_id};
|
override('stream_data.get_sub_by_id', function (stream_id) {
|
||||||
|
return {stream_id: stream_id};
|
||||||
|
});
|
||||||
|
override('stream_events.mark_subscribed', subscription_stub.f);
|
||||||
|
override('stream_data.update_stream_email_address', stream_email_stub.f);
|
||||||
|
dispatch(event);
|
||||||
|
var args = subscription_stub.get_args('sub', 'subscribers');
|
||||||
|
assert_same(args.sub.stream_id, event.subscriptions[0].stream_id);
|
||||||
|
assert_same(args.subscribers, event.subscriptions[0].subscribers);
|
||||||
|
args = stream_email_stub.get_args('sub', 'email_address');
|
||||||
|
assert_same(args.email_address, event.subscriptions[0].email_address);
|
||||||
|
assert_same(args.sub.stream_id, event.subscriptions[0].stream_id);
|
||||||
});
|
});
|
||||||
override('stream_events.mark_subscribed', stub.f);
|
|
||||||
dispatch(event);
|
|
||||||
var args = stub.get_args('sub', 'subscribers');
|
|
||||||
assert_same(args.sub.stream_id, event.subscriptions[0].stream_id);
|
|
||||||
assert_same(args.subscribers, event.subscriptions[0].subscribers);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
event = event_fixtures.subscription__peer_add;
|
event = event_fixtures.subscription__peer_add;
|
||||||
|
|||||||
@@ -192,6 +192,9 @@ zrequire('marked', 'third/marked/lib/marked');
|
|||||||
sub = stream_data.get_sub('Rome');
|
sub = stream_data.get_sub('Rome');
|
||||||
stream_data.update_subscribers_count(sub);
|
stream_data.update_subscribers_count(sub);
|
||||||
assert.equal(sub.subscriber_count, 1);
|
assert.equal(sub.subscriber_count, 1);
|
||||||
|
var sub_email = "Rome:214125235@zulipdev.com:9991";
|
||||||
|
stream_data.update_stream_email_address(sub, sub_email);
|
||||||
|
assert.equal(sub.email_address, sub_email);
|
||||||
|
|
||||||
// verify that adding an already-added subscriber is a noop
|
// verify that adding an already-added subscriber is a noop
|
||||||
stream_data.add_subscriber('Rome', brutus.user_id);
|
stream_data.add_subscriber('Rome', brutus.user_id);
|
||||||
|
|||||||
@@ -252,6 +252,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
|
|||||||
_.each(event.subscriptions, function (rec) {
|
_.each(event.subscriptions, function (rec) {
|
||||||
var sub = stream_data.get_sub_by_id(rec.stream_id);
|
var sub = stream_data.get_sub_by_id(rec.stream_id);
|
||||||
if (sub) {
|
if (sub) {
|
||||||
|
stream_data.update_stream_email_address(sub, rec.email_address);
|
||||||
stream_events.mark_subscribed(sub, rec.subscribers);
|
stream_events.mark_subscribed(sub, rec.subscribers);
|
||||||
} else {
|
} else {
|
||||||
blueslip.error('Subscribing to unknown stream with ID ' + rec.stream_id);
|
blueslip.error('Subscribing to unknown stream with ID ' + rec.stream_id);
|
||||||
|
|||||||
@@ -174,6 +174,10 @@ exports.update_subscribers_count = function (sub) {
|
|||||||
sub.subscriber_count = count;
|
sub.subscriber_count = count;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.update_stream_email_address = function (sub, email) {
|
||||||
|
sub.email_address = email;
|
||||||
|
};
|
||||||
|
|
||||||
exports.get_subscriber_count = function (stream_name) {
|
exports.get_subscriber_count = function (stream_name) {
|
||||||
var sub = exports.get_sub_by_name(stream_name);
|
var sub = exports.get_sub_by_name(stream_name);
|
||||||
if (sub === undefined) {
|
if (sub === undefined) {
|
||||||
|
|||||||
@@ -49,6 +49,11 @@ exports.hide_sub_settings = function (sub) {
|
|||||||
|
|
||||||
exports.show_sub_settings = function (sub) {
|
exports.show_sub_settings = function (sub) {
|
||||||
var $settings = $(".subscription_settings[data-stream-id='" + sub.stream_id + "']");
|
var $settings = $(".subscription_settings[data-stream-id='" + sub.stream_id + "']");
|
||||||
|
if ($settings.find(".email-address").val().length === 0) {
|
||||||
|
// Rerender stream email address, if not.
|
||||||
|
$settings.find(".email-address").html(sub.email_address);
|
||||||
|
$settings.find(".stream-email-box").show();
|
||||||
|
}
|
||||||
$settings.find(".regular_subscription_settings").addClass('in');
|
$settings.find(".regular_subscription_settings").addClass('in');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -96,14 +96,12 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
{{#if email_address}}
|
<div class="stream-email-box" {{#unless email_address}}style="display: none;"{{/unless}}>
|
||||||
<div class="stream-email-box">
|
|
||||||
<div class="sub_settings_title">{{t "Email address" }} <i class="icon-vector-question-sign stream-email-hint"></i></div>
|
<div class="sub_settings_title">{{t "Email address" }} <i class="icon-vector-question-sign stream-email-hint"></i></div>
|
||||||
<div class="stream-email">
|
<div class="stream-email">
|
||||||
<span class="email-address">{{email_address}}</span>
|
<span class="email-address">{{email_address}}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
|
||||||
</div>
|
</div>
|
||||||
<div class="subscription-members-setting">
|
<div class="subscription-members-setting">
|
||||||
{{partial "subscription_members"}}
|
{{partial "subscription_members"}}
|
||||||
|
|||||||
Reference in New Issue
Block a user