mirror of https://github.com/zulip/zulip.git
Safety check for stream_data:[add|remove]_subscriber
Though this should not be common, getting a peer subscribed/ unsubscribed notification to a stream we don't yet know about should not be fatal (imported from commit ee28b163e0efc9adfad31e1b321e986dfe56271e)
This commit is contained in:
parent
0165dc54ad
commit
f86c8255bb
|
@ -101,9 +101,10 @@ exports.get_name = function (stream_name) {
|
|||
|
||||
exports.add_subscriber = function (stream_name, user_email) {
|
||||
var sub = exports.get_sub(stream_name);
|
||||
if (!sub.subscribed) {
|
||||
if (typeof sub === 'undefined' || !sub.subscribed) {
|
||||
// If we're not subscribed, we don't track this, and shouldn't
|
||||
// get these events.
|
||||
// get these events. Likewise, if we don't know about the stream,
|
||||
// we don't want to track this.
|
||||
return;
|
||||
}
|
||||
sub.subscribers.set(user_email, true);
|
||||
|
@ -111,9 +112,10 @@ exports.add_subscriber = function (stream_name, user_email) {
|
|||
|
||||
exports.remove_subscriber = function (stream_name, user_email) {
|
||||
var sub = exports.get_sub(stream_name);
|
||||
if (!sub.subscribed) {
|
||||
if (typeof sub === 'undefined' || !sub.subscribed) {
|
||||
// If we're not subscribed, we don't track this, and shouldn't
|
||||
// get these events.
|
||||
// get these events. Likewise, if we don't know about the stream,
|
||||
// we don't want to track this.
|
||||
return;
|
||||
}
|
||||
sub.subscribers.del(user_email);
|
||||
|
|
Loading…
Reference in New Issue