mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 17:07:07 +00:00
compose: Get stream name from id in create_message_object.
Since this is based off of the id now and doesn't try to get a stream from a name (because stream is now selected by a dropdown and not a free-form input field), we can also remove the error handling for when the stream name doesn't correspond to any streams.
This commit is contained in:
@@ -6,7 +6,6 @@ import _ from "lodash";
|
||||
|
||||
import render_success_message_scheduled_banner from "../templates/compose_banner/success_message_scheduled_banner.hbs";
|
||||
|
||||
import * as blueslip from "./blueslip";
|
||||
import * as channel from "./channel";
|
||||
import * as compose_actions from "./compose_actions";
|
||||
import * as compose_banner from "./compose_banner";
|
||||
@@ -153,21 +152,12 @@ export function create_message_object() {
|
||||
message.to = people.user_ids_string_to_ids_array(message.to_user_ids);
|
||||
}
|
||||
} else {
|
||||
const stream_name = compose_state.stream_name();
|
||||
message.stream = stream_name;
|
||||
if (stream_name) {
|
||||
message.stream_id = compose_recipient.selected_recipient_id;
|
||||
message.to = compose_recipient.selected_recipient_id;
|
||||
} else {
|
||||
// We should be validating streams in calling code. We'll
|
||||
// try to fall back to stream_name here just in case the
|
||||
// user started composing to the old stream name and
|
||||
// manually entered the stream name, and it got past
|
||||
// validation. We should try to kill this code off eventually.
|
||||
blueslip.error("Trying to send message with bad stream name.");
|
||||
message.to = stream_name;
|
||||
}
|
||||
message.topic = topic;
|
||||
const stream_id = compose_state.stream_id();
|
||||
message.stream_id = stream_id;
|
||||
message.to = stream_id;
|
||||
const stream = stream_data.get_sub_by_id(stream_id);
|
||||
message.stream = stream ? stream.name : "";
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
@@ -738,14 +738,6 @@ test_ui("create_message_object", ({override, override_rewire}) => {
|
||||
assert.equal(message.topic, "lunch");
|
||||
assert.equal(message.content, "burrito");
|
||||
|
||||
blueslip.expect("error", "Unable to select stream: BOGUS STREAM");
|
||||
compose_state.set_stream_name("BOGUS STREAM");
|
||||
blueslip.expect("error", "Trying to send message with bad stream name.");
|
||||
message = compose.create_message_object();
|
||||
assert.equal(message.to, "");
|
||||
assert.equal(message.topic, "lunch");
|
||||
assert.equal(message.content, "burrito");
|
||||
|
||||
compose_state.set_message_type("private");
|
||||
override(compose_pm_pill, "get_emails", () => "alice@example.com,bob@example.com");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user