Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

compose: Get stream name from id in create_message_object.

evykassirer41b900c2c090
diff --git a/web/src/compose.js b/web/src/compose.js
index b174f2d0913..a6b048b3415 100644
--- a/web/src/compose.js
+++ b/web/src/compose.js
@@ -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;
}
diff --git a/web/tests/compose.test.js b/web/tests/compose.test.js
index e8dbdb0680b..5606bf7e5a9 100644
--- a/web/tests/compose.test.js
+++ b/web/tests/compose.test.js
@@ -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", () => "[email protected],[email protected]");