diff --git a/web/src/compose_actions.ts b/web/src/compose_actions.ts index 4b5a7f3136..824301f951 100644 --- a/web/src/compose_actions.ts +++ b/web/src/compose_actions.ts @@ -328,9 +328,19 @@ export let start = (raw_opts: ComposeActionsStartOpts): void => { if (opts.message_type === "private") { compose_state.set_compose_recipient_id(compose_state.DIRECT_MESSAGE_ID); compose_recipient.on_compose_select_recipient_update(); - } else if (opts.stream_id) { + } else if (opts.stream_id && opts.topic) { compose_state.set_stream_id(opts.stream_id); - compose_recipient.on_compose_select_recipient_update(); + } else if (opts.stream_id) { + const stream = stream_data.get_sub_by_id(opts.stream_id); + if (stream && stream_data.can_post_messages_in_stream(stream)) { + compose_state.set_stream_id(opts.stream_id); + compose_recipient.on_compose_select_recipient_update(); + } else { + opts.stream_id = undefined; + compose_state.set_stream_id(""); + opts.topic = ""; + compose_recipient.open_compose_recipient_dropdown(); + } } else { // Open stream selection dropdown if no stream is selected. compose_state.set_stream_id(""); diff --git a/web/tests/compose_actions.test.cjs b/web/tests/compose_actions.test.cjs index 242a128299..2e7b1edc4e 100644 --- a/web/tests/compose_actions.test.cjs +++ b/web/tests/compose_actions.test.cjs @@ -142,6 +142,7 @@ test("start", ({override, override_rewire, mock_template}) => { override_rewire(compose_actions, "clear_textarea", noop); override_rewire(compose_recipient, "on_compose_select_recipient_update", noop); override_rewire(compose_recipient, "check_posting_policy_for_compose_box", noop); + override_rewire(stream_data, "can_post_messages_in_stream", () => true); mock_template("inline_decorated_stream_name.hbs", false, noop); let compose_defaults; @@ -333,7 +334,6 @@ test("respond_to_message", ({override, override_rewire, mock_template}) => { test("reply_with_mention", ({override, override_rewire, mock_template}) => { mock_banners(); compose_state.set_message_type("stream"); - override_rewire(compose_recipient, "on_compose_select_recipient_update", noop); override_rewire(compose_actions, "complete_starting_tasks", noop); override_rewire(compose_actions, "clear_textarea", noop); override_private_message_recipient({override});