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.

filter: Add `mentions:` search operator for filtering by user mentions.

Aman Agrawal02000a53c64f
diff --git a/starlight_help/src/content/docs/search-for-messages.mdx b/starlight_help/src/content/docs/search-for-messages.mdx
index 248b41874a7..256adcbbce0 100644
--- a/starlight_help/src/content/docs/search-for-messages.mdx
+++ b/starlight_help/src/content/docs/search-for-messages.mdx
@@ -146,6 +146,8 @@ filters, to search additional messages.
received the message.
* `is:mentioned`: Search messages where you were
[mentioned](/help/mention-a-user-or-group).
+* `mentions:Elena García`: Search messages where Elena is
+ [mentioned](/help/mention-a-user-or-group).
* `is:starred`: Search your [starred messages](/help/star-a-message).
### Search by message status
diff --git a/web/src/filter.ts b/web/src/filter.ts
index e53772c4565..803992cbc29 100644
--- a/web/src/filter.ts
+++ b/web/src/filter.ts
@@ -227,6 +227,8 @@ function build_term_predicate(term: NarrowCanonicalTerm): ((message: Message) =>
// can_apply_locally() when a search term is present.
// istanbul ignore next
case "search":
+ // istanbul ignore next -- falls through
+ case "mentions":
throw new Error("build_term_predicate called for search term");
}
@@ -238,6 +240,7 @@ function build_term_predicate(term: NarrowCanonicalTerm): ((message: Message) =>
const USER_OPERATORS = new Set([
"dm-including",
"dm",
+ "mentions",
"sender",
"from",
"pm-with",
@@ -295,6 +298,7 @@ export class Filter {
case "topic":
break;
case "sender":
+ case "mentions":
case "dm":
case "dm-including":
break;
@@ -542,6 +546,20 @@ export class Filter {
};
break;
}
+ case "mentions": {
+ const operand = Number(suggestion.operand);
+
+ if (Number.isNaN(operand)) {
+ return undefined;
+ }
+
+ potential_narrow_term = {
+ operator: canonical_operator,
+ operand,
+ negated: suggestion.negated,
+ };
+ break;
+ }
default:
potential_narrow_term = {
operator: canonical_operator,
@@ -591,6 +609,7 @@ export class Filter {
case "topic":
return true;
case "sender":
+ case "mentions":
return people.is_valid_user_id(term.operand);
case "dm":
case "dm-including":
@@ -669,6 +688,7 @@ export class Filter {
"dm-including",
"with",
"sender",
+ "mentions",
"near",
"id",
"is-alerted",
@@ -741,6 +761,9 @@ export class Filter {
case "dm-including":
return verb + "direct messages including";
+ case "mentions":
+ return verb + "messages mentioning";
+
case "in":
return verb + "messages in";
@@ -1682,6 +1705,10 @@ export class Filter {
return false;
}
+ if (this.has_operator("mentions")) {
+ return false;
+ }
+
// If we get this far, we're good!
return true;
}
diff --git a/web/src/hash_util.ts b/web/src/hash_util.ts
index 6fbf131fd30..69251955345 100644
--- a/web/src/hash_util.ts
+++ b/web/src/hash_util.ts
@@ -44,6 +44,7 @@ export function encode_operand(term: NarrowCanonicalTerm): string {
slug = people.user_ids_to_slug(term.operand);
break;
case "sender":
+ case "mentions":
slug = people.user_ids_to_slug([term.operand]);
break;
case "channel":
@@ -81,13 +82,13 @@ export function decode_operand(
}
}
- if (operator === "sender") {
+ if (operator === "sender" || operator === "mentions") {
const user_ids = people.slug_to_user_ids(operand);
if (user_ids?.length !== 1) {
// User mistyped the URL since we don't support
- // group operand for `sender` narrow. Returning
- // -1 will lead to us showing a proper user
- // doesn't exist message in the UI.
+ // group operand for `sender` or `mentions` narrow.
+ // Returning -1 will lead to us showing a proper
+ // user doesn't exist message in the UI.
// Other options is to throw an error which will
// lead to us showing a "Invalid URL" banner which
// is not very nice looking.
diff --git a/web/src/narrow_banner.ts b/web/src/narrow_banner.ts
index cb5e3cf8494..7db4b12e6b1 100644
--- a/web/src/narrow_banner.ts
+++ b/web/src/narrow_banner.ts
@@ -529,6 +529,38 @@ export function pick_empty_narrow_banner(current_filter: Filter): NarrowBannerDa
),
};
}
+
+ case "mentions": {
+ const mentioned_user = people.maybe_get_user_by_id(first_term.operand, true);
+
+ if (!mentioned_user) {
+ return {
+ title: $t({defaultMessage: "This user does not exist!"}),
+ };
+ }
+
+ // mentions:me is redirected to is:mentioned in Filter.parse(),
+ // so mentioned_user will never be the current user here.
+ return {
+ title: $t(
+ {
+ defaultMessage: "No messages in your message history mention {person} yet.",
+ },
+ {person: mentioned_user.full_name},
+ ),
+ title_html: $t_html(
+ {
+ defaultMessage:
+ "No messages in <z-link>your message history</z-link> mention {person} yet.",
+ },
+ {
+ "z-link": (content_html) =>
+ `<a href="/help/search-for-messages#search-shared-history" target="_blank" rel="noopener noreferrer">${content_html.join("")}</a>`,
+ person: mentioned_user.full_name,
+ },
+ ),
+ };
+ }
}
return default_banner;
}
diff --git a/web/src/narrow_error.ts b/web/src/narrow_error.ts
index 5c611aa736b..9c4c409a89d 100644
--- a/web/src/narrow_error.ts
+++ b/web/src/narrow_error.ts
@@ -12,15 +12,22 @@ export type SearchData = {
export type NarrowBannerData = {
title: string;
+ title_html?: string;
html?: string;
search_data?: SearchData;
};
export function narrow_error(narrow_banner_data: NarrowBannerData): string {
const title = narrow_banner_data.title;
+ const title_html = narrow_banner_data.title_html;
const notice_html = narrow_banner_data.html;
const search_data = narrow_banner_data.search_data;
- const empty_feed_notice = render_empty_feed_notice({title, notice_html, search_data});
+ const empty_feed_notice = render_empty_feed_notice({
+ title,
+ title_html,
+ notice_html,
+ search_data,
+ });
return empty_feed_notice;
}
diff --git a/web/src/search_pill.ts b/web/src/search_pill.ts
index 35470f355ed..957a1873c4a 100644
--- a/web/src/search_pill.ts
+++ b/web/src/search_pill.ts
@@ -23,7 +23,7 @@ export type SearchUserPill = {
} & SearchUserPillContext;
export type SearchUserPillContext = {
- operator: "dm" | "dm-including" | "sender";
+ operator: "dm" | "dm-including" | "mentions" | "sender";
negated: boolean;
users: {
full_name: string;
@@ -71,6 +71,7 @@ export function get_search_string_from_item(item: SearchPill): string {
switch (item.operator) {
case "dm":
case "dm-including":
+ case "mentions":
case "sender":
assert(item.type === "search_user");
operand = item.users.map((user) => user.email).join(",");
@@ -207,6 +208,7 @@ export function generate_pills_html(suggestion: Suggestion, text_query: string):
switch (search_pill.operator) {
case "dm":
case "dm-including":
+ case "mentions":
case "sender":
return search_user_pill_data_from_term(narrow_term);
case "topic": {
@@ -362,6 +364,7 @@ export function create_pills($pill_container: JQuery): SearchPillWidget {
switch (item.operator) {
case "dm":
case "dm-including":
+ case "mentions":
case "sender":
assert(item.type === "search_user");
return render_search_user_pill(item);
@@ -392,7 +395,7 @@ export function create_pills($pill_container: JQuery): SearchPillWidget {
}
function get_user_ids_from_term_with_user_pill_operator(term: NarrowCanonicalTerm): number[] {
- if (term.operator === "sender") {
+ if (term.operator === "sender" || term.operator === "mentions") {
return [term.operand];
}
@@ -402,7 +405,10 @@ function get_user_ids_from_term_with_user_pill_operator(term: NarrowCanonicalTer
function search_user_pill_data_from_term(term: NarrowCanonicalTerm): SearchUserPill {
assert(
- term.operator === "dm" || term.operator === "dm-including" || term.operator === "sender",
+ term.operator === "dm" ||
+ term.operator === "dm-including" ||
+ term.operator === "mentions" ||
+ term.operator === "sender",
);
const user_ids = get_user_ids_from_term_with_user_pill_operator(term);
const users = user_ids.map((user_id) => people.get_by_user_id(user_id));
@@ -419,7 +425,7 @@ function is_sent_by_me_pill(pill: SearchUserPill): boolean {
function search_user_pill_data(
users: User[],
- operator: "dm" | "dm-including" | "sender",
+ operator: "dm" | "dm-including" | "mentions" | "sender",
negated: boolean,
): SearchUserPill {
return {
@@ -441,7 +447,7 @@ function search_user_pill_data(
function append_user_pill(
users: User[],
pill_widget: SearchPillWidget,
- operator: "dm" | "dm-including" | "sender",
+ operator: "dm" | "dm-including" | "mentions" | "sender",
negated: boolean,
): void {
const pill_data = search_user_pill_data(users, operator, negated);
@@ -496,6 +502,7 @@ export function set_search_bar_contents(
switch (term.operator) {
case "dm":
case "dm-including":
+ case "mentions":
case "sender": {
const user_ids = get_user_ids_from_term_with_user_pill_operator(narrow_term);
const users = user_ids.map((user_id) => people.get_by_user_id(user_id));
@@ -539,6 +546,7 @@ export function get_current_search_pill_terms(
negated: item.negated,
};
case "sender":
+ case "mentions":
assert(item.type === "search_user");
return {
operator: item.operator,
diff --git a/web/src/search_suggestion.ts b/web/src/search_suggestion.ts
index 2581fb13bff..b51b63f5fa6 100644
--- a/web/src/search_suggestion.ts
+++ b/web/src/search_suggestion.ts
@@ -134,6 +134,7 @@ const incompatible_patterns: Record<SearchFilter, TermPattern[]> = {
{operator: "topic"},
{operator: "channels"},
],
+ mentions: [{operator: "mentions"}],
sender: [{operator: "sender"}, {operator: "from"}],
"is:starred": [{operator: "is", operand: "starred"}],
"is:mentioned": [{operator: "is", operand: "mentioned"}],
@@ -404,7 +405,7 @@ function get_person_suggestions(
people_getter: () => User[],
last: NarrowCanonicalTermSuggestion,
terms: NarrowCanonicalTerm[],
- autocomplete_operator: "dm" | "sender" | "dm-including",
+ autocomplete_operator: "dm" | "sender" | "dm-including" | "mentions",
): Suggestion[] {
if (last.operator === "is" && last.operand === "dm") {
last = {operator: "dm", operand: "", negated: false};
@@ -432,8 +433,9 @@ function get_person_suggestions(
});
break;
case "sender":
+ case "mentions":
terms.push({
- operator: "sender",
+ operator: autocomplete_operator,
operand: person.user_id,
negated: last.negated,
});
@@ -876,6 +878,7 @@ function get_operator_suggestions(
"dm-including",
"sender",
"near",
+ "mentions",
];
legacy_operator_choices = ["from", "pm-with", "streams", "stream"];
}
@@ -934,6 +937,7 @@ function get_operator_suggestions(
true,
);
case "sender":
+ case "mentions":
return format_as_suggestion(
[
{
@@ -1112,7 +1116,7 @@ export let get_suggestions = function (
last = text_search_terms.at(-1)!;
}
- const person_suggestion_ops = ["sender", "dm", "dm-including"];
+ const person_suggestion_ops = ["sender", "dm", "dm-including", "mentions"];
// Handle spaces in person name in new suggestions only. Checks if the last operator is 'search'
// and the second last operator in search_terms is one out of person_suggestion_ops.
@@ -1161,7 +1165,7 @@ export let get_suggestions = function (
const people_getter = make_people_getter(last);
function get_people(
- flavor: "dm" | "sender" | "dm-including",
+ flavor: "dm" | "sender" | "dm-including" | "mentions",
): (last: NarrowCanonicalTermSuggestion, base_terms: NarrowCanonicalTerm[]) => Suggestion[] {
return function (
last: NarrowCanonicalTermSuggestion,
@@ -1187,6 +1191,7 @@ export let get_suggestions = function (
get_people("dm"),
get_people("sender"),
get_people("dm-including"),
+ get_people("mentions"),
get_topic_suggestions,
get_has_filter_suggestions,
];
diff --git a/web/src/state_data.ts b/web/src/state_data.ts
index 671918c3f62..1034ca51ca4 100644
--- a/web/src/state_data.ts
+++ b/web/src/state_data.ts
@@ -44,6 +44,7 @@ export const narrow_canonical_operator_schema = z.enum([
"id",
"in",
"is",
+ "mentions",
"near",
"search",
"sender",
@@ -123,6 +124,11 @@ export const narrow_canonical_term_schema = z.discriminatedUnion("operator", [
operand: z.string(),
negated: z.optional(z.boolean()),
}),
+ z.object({
+ operator: z.literal("mentions"),
+ operand: z.number(),
+ negated: z.optional(z.boolean()),
+ }),
z.object({
operator: z.literal("sender"),
operand: z.number(),
diff --git a/web/templates/empty_feed_notice.hbs b/web/templates/empty_feed_notice.hbs
index 39b9cfa391a..db9e8c1273b 100644
--- a/web/templates/empty_feed_notice.hbs
+++ b/web/templates/empty_feed_notice.hbs
@@ -1,5 +1,5 @@
<div class="empty_feed_notice">
- <h4 class="empty-feed-notice-title"> {{ title }} </h4>
+ <h4 class="empty-feed-notice-title"> {{#if title_html}}{{{ title_html }}}{{else}}{{ title }}{{/if}} </h4>
{{#if search_data}}
{{#if search_data.has_stop_word}}
<div class="empty-feed-notice-description">
diff --git a/web/templates/search_operators.hbs b/web/templates/search_operators.hbs
index 7099189a6ce..421d335f9f1 100644
--- a/web/templates/search_operators.hbs
+++ b/web/templates/search_operators.hbs
@@ -133,6 +133,15 @@
{{t 'Narrow to messages that mention you.'}}
</td>
</tr>
+ <tr>
+ <td class="operator">mentions:<span class="operator_value">user</span></td>
+ <td class="definition">
+ {{#tr}}
+ Narrow to messages that mention <z-value></z-value>.
+ {{#*inline "z-value"}}<span class="operator_value">user</span>{{/inline}}
+ {{/tr}}
+ </td>
+ </tr>
<tr>
<td class="operator">is:starred</td>
<td class="definition">
diff --git a/web/tests/filter.test.cjs b/web/tests/filter.test.cjs
index 79919ac4171..c03fa6fb631 100644
--- a/web/tests/filter.test.cjs
+++ b/web/tests/filter.test.cjs
@@ -676,6 +676,17 @@ test("basics", () => {
filter = new Filter(terms);
assert.ok(filter.is_channel_view());
+ terms = [{operator: "mentions", operand: joe.user_id}];
+ filter = new Filter(terms);
+ assert.ok(!filter.contains_only_private_messages());
+ assert.ok(!filter.has_operator("search"));
+ assert.ok(!filter.can_mark_messages_read());
+ assert.ok(!filter.contains_no_partial_conversations());
+ assert.ok(!filter.can_apply_locally());
+ assert.ok(!filter.is_personal_filter());
+ assert.ok(!filter.is_conversation_view());
+ assert.ok(!filter.is_channel_view());
+
// Throw error on invalid operator.
assert.throws(() => get_predicate([["bogus", "33"]]), {
name: "$ZodError",
@@ -1082,6 +1093,10 @@ test("canonicalization", () => {
term = Filter.canonicalize_term({operator: "has", operand: "reactions"});
assert.equal(term.operator, "has");
assert.equal(term.operand, "reaction");
+
+ term = Filter.canonicalize_term({operator: "mentions", operand: joe.user_id});
+ assert.equal(term.operator, "mentions");
+ assert.equal(term.operand, joe.user_id);
});
test("ensure_channel_topic_terms", () => {
@@ -1436,6 +1451,9 @@ test("predicate_basics", ({override}) => {
'<p><audio controls preload="metadata" src="/user_uploads/randompath/test.mp3" title="zulip.mp3"></audio></p>',
};
+ predicate = get_predicate([["mentions", joe.user_id]]);
+ assert.ok(predicate({}));
+
const inline_img_msg = {
content:
'<p><img alt="Screenshot" class="inline-image" data-original-content-type="image/png" data-original-dimensions="1488x1130" data-original-src="/user_uploads/randompath/test.png" src="/user_uploads/thumbnail/randompath/test.png/840x560.webp"></p>',
@@ -2006,6 +2024,10 @@ test("describe", ({mock_template, override}) => {
terms = [{operator: "dm-including", operand: ""}];
string = "direct messages including";
assert.equal(Filter.search_description_as_html(terms, true), string);
+
+ terms = [{operator: "mentions", operand: ""}];
+ string = "messages mentioning";
+ assert.equal(Filter.search_description_as_html(terms, true), string);
});
test("can_bucket_by", () => {
@@ -2235,6 +2257,9 @@ test("convert_suggestion_to_term", () => {
["sender:me", true],
[`dm:${[alice.user_id, -1]}`, false],
[`dm:${[alice.user_id, joe.user_id]}`, true],
+ [`mentions:${alice.user_id}`, true],
+ ["mentions:-1", false],
+ ["mentions:invalid", false],
];
for (const [search_term_string, expected_is_valid] of test_data) {
assert.equal(
@@ -3050,6 +3075,9 @@ run_test("is_spectator_compatible", () => {
assert.ok(
!Filter.is_spectator_compatible([{operator: "group-pm-with", operand: "[email protected]"}]),
);
+ assert.ok(
+ !Filter.is_spectator_compatible([{operator: "mentions", operand: "[email protected]"}]),
+ );
});
run_test("is_in_home", () => {
diff --git a/web/tests/message_view.test.cjs b/web/tests/message_view.test.cjs
index 77189aec8ac..94fbbf59de1 100644
--- a/web/tests/message_view.test.cjs
+++ b/web/tests/message_view.test.cjs
@@ -61,9 +61,10 @@ mock_esm("../src/spectators", {
login_to_access() {},
});
-function empty_narrow_html(title, notice_html, search_data) {
+function empty_narrow_html(title, notice_html, search_data, title_html) {
const opts = {
title,
+ title_html,
notice_html,
search_data,
};
@@ -579,6 +580,25 @@ run_test("show_empty_narrow_message", ({mock_template, override, override_rewire
empty_narrow_html("translated: No search results."),
);
+ current_filter = set_filter([["mentions", alice.user_id]]);
+ narrow_banner.show_empty_narrow_message(current_filter);
+ assert.equal(
+ $(".empty_feed_notice_main").html(),
+ empty_narrow_html(
+ "translated: No messages in your message history mention Alice Smith yet.",
+ undefined,
+ undefined,
+ 'translated: No messages in <a href="/help/search-for-messages#search-shared-history" target="_blank" rel="noopener noreferrer">your message history</a> mention Alice Smith yet.',
+ ),
+ );
+
+ current_filter = set_filter([["mentions", -1]]);
+ narrow_banner.show_empty_narrow_message(current_filter);
+ assert.equal(
+ $(".empty_feed_notice_main").html(),
+ empty_narrow_html("translated: This user does not exist!"),
+ );
+
current_filter = set_filter([["is", "invalid"]]);
narrow_banner.show_empty_narrow_message(current_filter);
assert.equal(
diff --git a/web/tests/search.test.cjs b/web/tests/search.test.cjs
index ac5115cbb6c..af3cc187fc0 100644
--- a/web/tests/search.test.cjs
+++ b/web/tests/search.test.cjs
@@ -133,6 +133,7 @@ run_test("initialize", ({override, override_rewire, mock_template}) => {
`sender:${zoe.user_id}`,
`dm:${zoe.user_id}`,
`dm-including:${zoe.user_id}`,
+ `mentions:${zoe.user_id}`,
];
/* Test highlighter */
@@ -150,6 +151,9 @@ run_test("initialize", ({override, override_rewire, mock_template}) => {
expected_value = `<div class="search_list_item">\n <span class="pill-container"><div class="user-pill-container pill" tabindex=0>\n <span class="pill-label">dm-including:\n </span>\n <div class="pill" data-user-id="3">\n <img class="pill-image" src="/avatar/3" />\n <div class="pill-image-border"></div>\n <span class="pill-label">\n <span class="pill-value">Zoe</span></span>\n <div class="exit">\n <a role="button" class="zulip-icon zulip-icon-close pill-close-button"></a>\n </div>\n </div>\n</div>\n</span>\n \n</div>\n`;
assert.equal(opts.item_html("zo")(search_suggestions[3]), expected_value);
+ expected_value = `<div class="search_list_item">\n <span class="pill-container"><div class="user-pill-container pill" tabindex=0>\n <span class="pill-label">mentions:\n </span>\n <div class="pill" data-user-id="3">\n <img class="pill-image" src="/avatar/3" />\n <div class="pill-image-border"></div>\n <span class="pill-label">\n <span class="pill-value">Zoe</span></span>\n <div class="exit">\n <a role="button" class="zulip-icon zulip-icon-close pill-close-button"></a>\n </div>\n </div>\n</div>\n</span>\n \n</div>\n`;
+ assert.equal(opts.item_html(search_suggestions[4], "zo"), expected_value);
+
/* Test sorter */
assert.equal(opts.sorter(search_suggestions.strings), search_suggestions.strings);
}
diff --git a/web/tests/search_suggestion.test.cjs b/web/tests/search_suggestion.test.cjs
index ace627432a3..986087d3d86 100644
--- a/web/tests/search_suggestion.test.cjs
+++ b/web/tests/search_suggestion.test.cjs
@@ -183,6 +183,7 @@ test("dm_suggestions", ({override}) => {
`is:dm dm:${alice.user_id}`,
`is:dm sender:${alice.user_id}`,
`is:dm dm-including:${alice.user_id}`,
+ `is:dm mentions:${alice.user_id}`,
];
assert.deepEqual(suggestions, expected);
@@ -273,6 +274,7 @@ test("dm_suggestions", ({override}) => {
`is:starred has:link is:dm dm:${alice.user_id}`,
`is:starred has:link is:dm sender:${alice.user_id}`,
`is:starred has:link is:dm dm-including:${alice.user_id}`,
+ `is:starred has:link is:dm mentions:${alice.user_id}`,
];
assert.deepEqual(suggestions, expected);
@@ -307,6 +309,7 @@ test("group_suggestions", () => {
`dm:${bob.user_id},${alice.user_id}`,
`dm:${bob.user_id} sender:${alice.user_id}`,
`dm:${bob.user_id} dm-including:${alice.user_id}`,
+ `dm:${bob.user_id} mentions:${alice.user_id}`,
];
assert.deepEqual(suggestions, expected);
@@ -318,6 +321,7 @@ test("group_suggestions", () => {
`dm:${ted.user_id} my`,
`dm:${ted.user_id} sender:${me.user_id}`,
`dm:${ted.user_id} dm-including:${me.user_id}`,
+ `dm:${ted.user_id} mentions:${me.user_id}`,
];
assert.deepEqual(suggestions, expected);
@@ -339,6 +343,7 @@ test("group_suggestions", () => {
`dm:${bob.user_id},${alice.user_id}`,
`dm:${bob.user_id} sender:${alice.user_id}`,
`dm:${bob.user_id} dm-including:${alice.user_id}`,
+ `dm:${bob.user_id} mentions:${alice.user_id}`,
];
assert.deepEqual(suggestions, expected);
@@ -351,6 +356,7 @@ test("group_suggestions", () => {
`is:starred has:link dm:${bob.user_id},${ted.user_id}`,
`is:starred has:link dm:${bob.user_id} sender:${ted.user_id}`,
`is:starred has:link dm:${bob.user_id} dm-including:${ted.user_id}`,
+ `is:starred has:link dm:${bob.user_id} mentions:${ted.user_id}`,
];
assert.deepEqual(suggestions, expected);
@@ -504,6 +510,7 @@ test("check_is_suggestions", ({override}) => {
`dm:${alice.user_id}`,
`sender:${alice.user_id}`,
`dm-including:${alice.user_id}`,
+ `mentions:${alice.user_id}`,
"has:image",
];
assert.deepEqual(suggestions, expected);
@@ -668,7 +675,13 @@ test("topic_suggestions", ({override, override_rewire}) => {
);
suggestions = get_suggestions("te");
- expected = ["te", `dm:${ted.user_id}`, `sender:${ted.user_id}`, `dm-including:${ted.user_id}`];
+ expected = [
+ "te",
+ `dm:${ted.user_id}`,
+ `sender:${ted.user_id}`,
+ `dm-including:${ted.user_id}`,
+ `mentions:${ted.user_id}`,
+ ];
assert.deepEqual(suggestions, expected);
stream_topic_history.add_message({
@@ -689,6 +702,7 @@ test("topic_suggestions", ({override, override_rewire}) => {
`dm:${ted.user_id}`,
`sender:${ted.user_id}`,
`dm-including:${ted.user_id}`,
+ `mentions:${ted.user_id}`,
`channel:${office_id} topic:team`,
`channel:${office_id} topic:✔+team+work`,
`channel:${office_id} topic:test`,
@@ -995,6 +1009,8 @@ test("people_suggestions", ({override}) => {
`sender:${ted.user_id}`,
`dm-including:${bob.user_id}`,
`dm-including:${ted.user_id}`,
+ `mentions:${bob.user_id}`,
+ `mentions:${ted.user_id}`,
];
assert.deepEqual(suggestions, expected);
@@ -1018,12 +1034,21 @@ test("people_suggestions", ({override}) => {
`dm-including:${bob.user_id}`,
`dm-including:${ted.user_id}`,
`dm-including:${inaccessible_user.user_id}`,
+ `mentions:${bob.user_id}`,
+ `mentions:${ted.user_id}`,
+ `mentions:${inaccessible_user.user_id}`,
];
assert.deepEqual(suggestions, expected);
suggestions = get_suggestions("Ted "); // note space
- expected = ["Ted", `dm:${ted.user_id}`, `sender:${ted.user_id}`, `dm-including:${ted.user_id}`];
+ expected = [
+ "Ted",
+ `dm:${ted.user_id}`,
+ `sender:${ted.user_id}`,
+ `dm-including:${ted.user_id}`,
+ `mentions:${ted.user_id}`,
+ ];
assert.deepEqual(suggestions, expected);