Trim leading and trailing spaces for search terms (#10989)
Этот коммит содержится в:
@@ -1761,6 +1761,7 @@ func (a *App) UpdateChannelLastViewedAt(channelIds []string, userId string) *mod
|
||||
|
||||
func (a *App) AutocompleteChannels(teamId string, term string) (*model.ChannelList, *model.AppError) {
|
||||
includeDeleted := *a.Config().TeamSettings.ExperimentalViewArchivedChannels
|
||||
term = strings.TrimSpace(term)
|
||||
|
||||
esInterface := a.Elasticsearch
|
||||
license := a.License()
|
||||
@@ -1797,6 +1798,8 @@ func (a *App) AutocompleteChannels(teamId string, term string) (*model.ChannelLi
|
||||
func (a *App) AutocompleteChannelsForSearch(teamId string, userId string, term string) (*model.ChannelList, *model.AppError) {
|
||||
includeDeleted := *a.Config().TeamSettings.ExperimentalViewArchivedChannels
|
||||
|
||||
term = strings.TrimSpace(term)
|
||||
|
||||
result := <-a.Srv.Store.Channel().AutocompleteInTeamForSearch(teamId, userId, term, includeDeleted)
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
@@ -1814,6 +1817,9 @@ func (a *App) SearchAllChannels(term string, opts model.ChannelSearchOpts) (*mod
|
||||
NotAssociatedToGroup: opts.NotAssociatedToGroup,
|
||||
IncludeDeleted: opts.IncludeDeleted,
|
||||
}
|
||||
|
||||
term = strings.TrimSpace(term)
|
||||
|
||||
result := <-a.Srv.Store.Channel().SearchAllChannels(term, storeOpts)
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
@@ -1824,6 +1830,8 @@ func (a *App) SearchAllChannels(term string, opts model.ChannelSearchOpts) (*mod
|
||||
func (a *App) SearchChannels(teamId string, term string) (*model.ChannelList, *model.AppError) {
|
||||
includeDeleted := *a.Config().TeamSettings.ExperimentalViewArchivedChannels
|
||||
|
||||
term = strings.TrimSpace(term)
|
||||
|
||||
result := <-a.Srv.Store.Channel().SearchInTeam(teamId, term, includeDeleted)
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
@@ -1832,6 +1840,7 @@ func (a *App) SearchChannels(teamId string, term string) (*model.ChannelList, *m
|
||||
}
|
||||
|
||||
func (a *App) SearchChannelsUserNotIn(teamId string, userId string, term string) (*model.ChannelList, *model.AppError) {
|
||||
term = strings.TrimSpace(term)
|
||||
result := <-a.Srv.Store.Channel().SearchMore(userId, teamId, term)
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
|
||||
@@ -855,7 +855,7 @@ func (a *App) SearchPostsInTeam(teamId string, paramsList []*model.SearchParams)
|
||||
}
|
||||
|
||||
func (a *App) SearchPostsInTeamForUser(terms string, userId string, teamId string, isOrSearch bool, includeDeletedChannels bool, timeZoneOffset int, page, perPage int) (*model.PostSearchResults, *model.AppError) {
|
||||
paramsList := model.ParseSearchParams(terms, timeZoneOffset)
|
||||
paramsList := model.ParseSearchParams(strings.TrimSpace(terms), timeZoneOffset)
|
||||
includeDeleted := includeDeletedChannels && *a.Config().TeamSettings.ExperimentalViewArchivedChannels
|
||||
|
||||
esInterface := a.Elasticsearch
|
||||
|
||||
10
app/user.go
10
app/user.go
@@ -1666,6 +1666,7 @@ func (a *App) SearchUsers(props *model.UserSearch, options *model.UserSearchOpti
|
||||
}
|
||||
|
||||
func (a *App) SearchUsersInChannel(channelId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
term = strings.TrimSpace(term)
|
||||
result := <-a.Srv.Store.User().SearchInChannel(channelId, term, options)
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
@@ -1680,6 +1681,7 @@ func (a *App) SearchUsersInChannel(channelId string, term string, options *model
|
||||
}
|
||||
|
||||
func (a *App) SearchUsersNotInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
term = strings.TrimSpace(term)
|
||||
result := <-a.Srv.Store.User().SearchNotInChannel(teamId, channelId, term, options)
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
@@ -1696,6 +1698,8 @@ func (a *App) SearchUsersNotInChannel(teamId string, channelId string, term stri
|
||||
func (a *App) SearchUsersInTeam(teamId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
var result store.StoreResult
|
||||
|
||||
term = strings.TrimSpace(term)
|
||||
|
||||
esInterface := a.Elasticsearch
|
||||
license := a.License()
|
||||
if esInterface != nil && *a.Config().ElasticsearchSettings.EnableAutocomplete && license != nil && *license.Features.Elasticsearch {
|
||||
@@ -1730,6 +1734,7 @@ func (a *App) SearchUsersInTeam(teamId string, term string, options *model.UserS
|
||||
}
|
||||
|
||||
func (a *App) SearchUsersNotInTeam(notInTeamId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
term = strings.TrimSpace(term)
|
||||
result := <-a.Srv.Store.User().SearchNotInTeam(notInTeamId, term, options)
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
@@ -1744,6 +1749,7 @@ func (a *App) SearchUsersNotInTeam(notInTeamId string, term string, options *mod
|
||||
}
|
||||
|
||||
func (a *App) SearchUsersWithoutTeam(term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {
|
||||
term = strings.TrimSpace(term)
|
||||
result := <-a.Srv.Store.User().SearchWithoutTeam(term, options)
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
@@ -1760,6 +1766,8 @@ func (a *App) SearchUsersWithoutTeam(term string, options *model.UserSearchOptio
|
||||
func (a *App) AutocompleteUsersInChannel(teamId string, channelId string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInChannel, *model.AppError) {
|
||||
var uchan, nuchan store.StoreChannel
|
||||
|
||||
term = strings.TrimSpace(term)
|
||||
|
||||
esInterface := a.Elasticsearch
|
||||
license := a.License()
|
||||
if esInterface != nil && *a.Config().ElasticsearchSettings.EnableAutocomplete && license != nil && *license.Features.Elasticsearch {
|
||||
@@ -1820,6 +1828,8 @@ func (a *App) AutocompleteUsersInTeam(teamId string, term string, options *model
|
||||
autocomplete := &model.UserAutocompleteInTeam{}
|
||||
var result store.StoreResult
|
||||
|
||||
term = strings.TrimSpace(term)
|
||||
|
||||
esInterface := a.Elasticsearch
|
||||
license := a.License()
|
||||
if esInterface != nil && *a.Config().ElasticsearchSettings.EnableAutocomplete && license != nil && *license.Features.Elasticsearch {
|
||||
|
||||
Ссылка в новой задаче
Block a user