From 3d4374f2a610cc6866a960d5a8826530eab7d721 Mon Sep 17 00:00:00 2001 From: evykassirer Date: Wed, 9 Nov 2022 16:45:15 -0800 Subject: [PATCH] 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. --- frontend_tests/node_tests/stream_data.js | 3 +++ static/js/stream_data.js | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/frontend_tests/node_tests/stream_data.js b/frontend_tests/node_tests/stream_data.js index af7891d975..b1f5a092c9 100644 --- a/frontend_tests/node_tests/stream_data.js +++ b/frontend_tests/node_tests/stream_data.js @@ -992,4 +992,7 @@ test("can_post_messages_in_stream", () => { social.stream_post_policy = stream_data.stream_post_policy_values.everyone.code; 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); }); diff --git a/static/js/stream_data.js b/static/js/stream_data.js index 06efc17a9c..847484a38b 100644 --- a/static/js/stream_data.js +++ b/static/js/stream_data.js @@ -557,6 +557,10 @@ export function can_subscribe_others(sub) { } export function can_post_messages_in_stream(stream) { + if (page_params.is_spectator) { + return false; + } + if (page_params.is_admin) { return true; }