Ignore "@" sign at the beginning of user searches (#9780)

This trims the "@" symbol from the begging of the search term before executing the query.
Этот коммит содержится в:
Daniel Fiori
2018-11-12 15:54:12 -05:00
коммит произвёл Christopher Speller
родитель 7a758eae72
Коммит fa0aecce1e
2 изменённых файлов: 11 добавлений и 1 удалений

Просмотреть файл

@@ -1166,7 +1166,7 @@ func generateSearchQuery(searchQuery string, terms []string, fields []string, pa
} }
} }
searchTerms = append(searchTerms, fmt.Sprintf("(%s)", strings.Join(searchFields, " OR "))) searchTerms = append(searchTerms, fmt.Sprintf("(%s)", strings.Join(searchFields, " OR ")))
parameters[fmt.Sprintf("Term%d", i)] = fmt.Sprintf("%s%%", term) parameters[fmt.Sprintf("Term%d", i)] = fmt.Sprintf("%s%%", strings.TrimLeft(term, "@"))
} }
searchClause := strings.Join(searchTerms, " AND ") searchClause := strings.Join(searchTerms, " AND ")

Просмотреть файл

@@ -1658,6 +1658,16 @@ func testUserStoreSearch(t *testing.T, ss store.Store) {
}, },
[]*model.User{u1}, []*model.User{u1},
}, },
{
"leading @ should be ignored",
tid,
"@jimb",
&model.UserSearchOptions{
AllowFullNames: true,
Limit: model.USER_SEARCH_DEFAULT_LIMIT,
},
[]*model.User{u1},
},
} }
for _, testCase := range testCases { for _, testCase := range testCases {