subscription: Fix unexpected blueslip warnings on add subscriber.

In stream settings, if user add subscriber to unsubscribed public
stream from `Add` input widget it gives lots of blueslip warnings,
cause user isn't subscribed to public stream.

Fix this by changing condition to `sub.can_access_subscriber` from
`sub.subscribed` in blueslip warning, cause user can access
subscribers in such cases even if not subscribed to stream.

Tweaked by tabbott to make the node tests pass.
This commit is contained in:
YJDave
2018-03-19 10:22:37 +05:30
committed by Tim Abbott
parent 64dac1bb2e
commit 2cbfcbb740
4 changed files with 34 additions and 10 deletions

View File

@@ -363,11 +363,10 @@ exports.remove_subscriber = function (stream_name, user_id) {
exports.user_is_subscribed = function (stream_name, user_email) {
var sub = exports.get_sub(stream_name);
if (typeof sub === 'undefined' || !sub.subscribed) {
// If we don't know about the stream, or we ourselves are not
// subscribed, we can't keep track of the subscriber list in general,
if (typeof sub === 'undefined' || !sub.can_access_subscribers) {
// If we don't know about the stream, or we ourselves can not access subscriber list,
// so we return undefined (treated as falsy if not explicitly handled).
blueslip.warn("We got a user_is_subscribed call for a non-existent or unsubscribed stream.");
blueslip.warn("We got a user_is_subscribed call for a non-existent or inaccessible stream.");
return;
}
var user_id = people.get_user_id(user_email);