search: Fix searching and search suggestion in Group PM.

Fix the .get_suggestions and .get_suggestions_legacy
to correctly handle search terms in group PM and treat
it as search term by not concatenating it at end of pm-with
email list operand.
This commit is contained in:
Mohit Gupta 2019-06-27 22:46:55 +05:30 committed by Tim Abbott
parent bf9e0c3239
commit 487861554f
3 changed files with 18 additions and 2 deletions

View File

@ -422,6 +422,13 @@ run_test('group_suggestions', () => {
"pm-with:jeff@zulip.com,ted@zulip.com",
];
assert.deepEqual(suggestions.strings, expected);
query = "pm-with:jeff@zulip.com,ted@zulip.com hi";
suggestions = search.get_suggestions("", query);
expected = [
"pm-with:jeff@zulip.com,ted@zulip.com hi",
];
assert.deepEqual(suggestions.strings, expected);
});
init();

View File

@ -426,6 +426,15 @@ run_test('group_suggestions', () => {
"pm-with:jeff@zulip.com,ted@zulip.com",
];
assert.deepEqual(suggestions.strings, expected);
query = "pm-with:jeff@zulip.com,ted@zulip.com hi";
suggestions = search.get_suggestions_legacy(query);
expected = [
"pm-with:jeff@zulip.com,ted@zulip.com hi",
"pm-with:jeff@zulip.com,ted@zulip.com",
];
assert.deepEqual(suggestions.strings, expected);
});
init();

View File

@ -588,7 +588,7 @@ exports.get_suggestions = function (base_query, query) {
last.operator === 'search' &&
person_suggestion_ops.indexOf(query_operators[query_operators_len - 2].operator) !== -1) {
var person_op = query_operators[query_operators_len - 2];
if (!people.get_by_email(person_op.operand)) {
if (!people.reply_to_to_user_ids_string(person_op.operand)) {
last = {
operator: person_op.operator,
operand: person_op.operand + ' ' + last.operand,
@ -713,7 +713,7 @@ exports.get_suggestions_legacy = function (query) {
last.operator === 'search' &&
person_suggestion_ops.indexOf(operators[operators_len - 2].operator) !== -1) {
var person_op = operators[operators_len - 2];
if (!people.get_by_email(person_op.operand)) {
if (!people.reply_to_to_user_ids_string(person_op.operand)) {
last = {
operator: person_op.operator,
operand: person_op.operand + ' ' + last.operand,