mirror of https://github.com/zulip/zulip.git
streams: Hide unsubscribed streams in settings to guest users.
This commit is contained in:
parent
80ceb1a46d
commit
2598db4a77
|
@ -1,6 +1,7 @@
|
|||
set_global('page_params', {
|
||||
is_admin: false,
|
||||
realm_users: [],
|
||||
is_guest: false,
|
||||
});
|
||||
|
||||
set_global('$', function () {
|
||||
|
@ -427,6 +428,15 @@ run_test('stream_settings', () => {
|
|||
assert.equal(sub.invite_only, false);
|
||||
assert.equal(sub.history_public_to_subscribers, false);
|
||||
assert.equal(sub.is_announcement_only, false);
|
||||
|
||||
// For guest user only retrieve subscribed streams
|
||||
sub_rows = stream_data.get_updated_unsorted_subs();
|
||||
assert.equal(sub_rows.length, 3);
|
||||
global.page_params.is_guest = true;
|
||||
sub_rows = stream_data.get_updated_unsorted_subs();
|
||||
assert.equal(sub_rows[0].name, 'c');
|
||||
assert.equal(sub_rows[1].name, 'a');
|
||||
assert.equal(sub_rows.length, 2);
|
||||
});
|
||||
|
||||
run_test('default_stream_names', () => {
|
||||
|
|
|
@ -5,6 +5,7 @@ set_global('ui', {});
|
|||
zrequire('util');
|
||||
zrequire('stream_data');
|
||||
zrequire('search_util');
|
||||
set_global('page_params', {});
|
||||
|
||||
global.patch_builtin('window', {
|
||||
location: {
|
||||
|
|
|
@ -194,6 +194,13 @@ exports.get_updated_unsorted_subs = function () {
|
|||
exports.update_calculated_fields(sub);
|
||||
});
|
||||
|
||||
// We don't display unsubscribed streams to guest users.
|
||||
if (page_params.is_guest) {
|
||||
all_subs = _.reject(all_subs, function (sub) {
|
||||
return !sub.subscribed;
|
||||
});
|
||||
}
|
||||
|
||||
return all_subs;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue