streams: Return early from can_post_messages_in_stream for spectators.

This code path isn't currently reached for the logged out "spectator"
view, but it will be in upcoming commits. This makes sure that case
is handled properly.
This commit is contained in:
evykassirer 2022-11-09 16:45:15 -08:00 committed by Tim Abbott
parent 763dfbdcfb
commit 3d4374f2a6
2 changed files with 7 additions and 0 deletions

View File

@ -992,4 +992,7 @@ test("can_post_messages_in_stream", () => {
social.stream_post_policy = stream_data.stream_post_policy_values.everyone.code; social.stream_post_policy = stream_data.stream_post_policy_values.everyone.code;
assert.equal(stream_data.can_post_messages_in_stream(social), true); assert.equal(stream_data.can_post_messages_in_stream(social), true);
page_params.is_spectator = true;
assert.equal(stream_data.can_post_messages_in_stream(social), false);
}); });

View File

@ -557,6 +557,10 @@ export function can_subscribe_others(sub) {
} }
export function can_post_messages_in_stream(stream) { export function can_post_messages_in_stream(stream) {
if (page_params.is_spectator) {
return false;
}
if (page_params.is_admin) { if (page_params.is_admin) {
return true; return true;
} }