mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
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:
@@ -101,9 +101,10 @@ exports.get_name = function (stream_name) {
|
|||||||
|
|
||||||
exports.add_subscriber = function (stream_name, user_email) {
|
exports.add_subscriber = function (stream_name, user_email) {
|
||||||
var sub = exports.get_sub(stream_name);
|
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
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
sub.subscribers.set(user_email, true);
|
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) {
|
exports.remove_subscriber = function (stream_name, user_email) {
|
||||||
var sub = exports.get_sub(stream_name);
|
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
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
sub.subscribers.del(user_email);
|
sub.subscribers.del(user_email);
|
||||||
|
|||||||
Reference in New Issue
Block a user