Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
message_helper: Be more explicit about converting subject to topic.
evykassirer28107eb91384
diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.pyindex fa29914feb4..61d35109778 100644--- a/tools/linter_lib/custom_check.py+++ b/tools/linter_lib/custom_check.py@@ -124,6 +124,7 @@ js_rules = RuleList("web/src/message_store.ts","web/src/types.ts","web/src/util.ts",+ "web/src/message_helper.ts","web/tests/",},"exclude_pattern": "emails",diff --git a/web/src/message_helper.js b/web/src/message_helper.jsindex 92ef4faa6b6..6a38cef6713 100644--- a/web/src/message_helper.js+++ b/web/src/message_helper.js@@ -38,7 +38,10 @@ export function process_new_message(message) {switch (message.type) {case "stream":- util.convert_message_topic(message);+ if (message.topic === undefined) {+ message.topic = message.subject;+ }+ delete message.subject;message.is_stream = true;message.reply_to = message.sender_email;diff --git a/web/src/util.ts b/web/src/util.tsindex 044e3d10f97..58f5454eda5 100644--- a/web/src/util.ts+++ b/web/src/util.ts@@ -269,12 +269,6 @@ export function is_topic_synonym(operator: string): boolean {return operator === "subject";}-export function convert_message_topic(message: Message): void {- if (message.type === "stream" && message.topic === undefined) {- message.topic = message.subject;- }-}-// TODO: When "stream" is renamed to "channel", update these stream// synonym helper functions for the reverse logic.export function is_stream_synonym(text: string): boolean {diff --git a/web/tests/example2.test.js b/web/tests/example2.test.jsindex 4bfa7daed1c..be41ae55019 100644--- a/web/tests/example2.test.js+++ b/web/tests/example2.test.js@@ -42,7 +42,7 @@ const messages = {stream_id: denmark_stream.stream_id,type: "stream",flags: ["has_alert_word"],- topic: "copenhagen",+ subject: "copenhagen",// note we don't have every field that a "real" message// would have, and that can be fine},@@ -91,7 +91,7 @@ run_test("unread", () => {assert.equal(unread.num_unread_for_topic(stream_id, topic_name), 0);let in_message = {...messages.isaac_to_denmark_stream};- in_message = message_store.set_message_booleans(in_message);+ in_message = message_helper.process_new_message(in_message);unread.process_loaded_messages([in_message]);assert.equal(unread.num_unread_for_topic(stream_id, topic_name), 1);