stream_data: Fix exception when notifications_stream is private.

If notifications_stream is private and the current user has never been
subscribed, then we would throw an exception when trying to look up
notifications_stream.  In this situation, we should just treat it like
the stream doesn't exist for the purposes of this user.
This commit is contained in:
Tim Abbott
2018-05-03 08:28:38 -07:00
parent 1e1b72f6c8
commit 0ada5fa9d8
2 changed files with 16 additions and 3 deletions

View File

@@ -645,6 +645,13 @@ zrequire('marked', 'third/marked/lib/marked');
assert(!page_params.never_subscribed);
assert.equal(page_params.notifications_stream, "");
// Simulate a private stream the user isn't subscribed to
initialize();
page_params.realm_notifications_stream_id = 89;
stream_data.initialize_from_page_params();
assert.equal(page_params.notifications_stream, "");
// Now actually subscribe the user to the stream
initialize();
var foo = {
name: 'foo',
@@ -652,7 +659,6 @@ zrequire('marked', 'third/marked/lib/marked');
};
stream_data.add_sub('foo', foo);
page_params.realm_notifications_stream_id = 89;
stream_data.initialize_from_page_params();
assert.equal(page_params.notifications_stream, "foo");