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.

mentions: Replace "channel" wildcard when selected via typeahead.

Lauryn Menard80d4a704fe12
diff --git a/web/src/people.ts b/web/src/people.ts
index 1dd8b32fd3f..22c9897c1b3 100644
--- a/web/src/people.ts
+++ b/web/src/people.ts
@@ -1360,8 +1360,13 @@ export function get_mention_syntax(full_name: string, user_id?: number, silent =
} else {
mention += "@**";
}
- mention += full_name;
const wildcard_match = full_name_matches_wildcard_mention(full_name);
+ if (wildcard_match && user_id === undefined) {
+ mention += util.canonicalize_stream_synonym(full_name);
+ } else {
+ mention += full_name;
+ }
+
if (user_id === undefined && !wildcard_match) {
blueslip.warn("get_mention_syntax called without user_id.");
}
diff --git a/web/src/util.ts b/web/src/util.ts
index 23d4f093b4b..1b44005a1ee 100644
--- a/web/src/util.ts
+++ b/web/src/util.ts
@@ -275,6 +275,19 @@ export function convert_message_topic(message: Message): void {
}
}
+// 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 {
+ return text === "channel";
+}
+
+export function canonicalize_stream_synonym(text: string): string {
+ if (is_stream_synonym(text.toLowerCase())) {
+ return "stream";
+ }
+ return text;
+}
+
let inertDocument: Document | undefined;
export function clean_user_content_links(html: string): string {
diff --git a/web/tests/people.test.js b/web/tests/people.test.js
index 030197f40a3..0b114317ef7 100644
--- a/web/tests/people.test.js
+++ b/web/tests/people.test.js
@@ -1154,6 +1154,7 @@ test_people("get_mention_syntax", () => {
assert.equal(people.get_mention_syntax("all"), "@**all**");
assert.equal(people.get_mention_syntax("everyone", undefined, true), "@_**everyone**");
assert.equal(people.get_mention_syntax("stream"), "@**stream**");
+ assert.equal(people.get_mention_syntax("channel"), "@**stream**");
assert.equal(people.get_mention_syntax("topic"), "@**topic**");
people.add_active_user(stephen1);