Pr 9039 (#9187)
* MM-11065: Allow to search and get archived channels from the API * Fixing more tests * Add some unit tests * Add includeDeleted parameter to session permissions check function * More test fixing * Adding archive channels list in channels search * Add restriction for archived channel edition * Reverting permissions checks modification * Changed the query parameter to include_deleted * Enable search archive channels as true by default * Adding tests for verify search on deleted channels * Allowing to override archive channels during the imports * Fixed test * Search in archive channels from the API must be explicitly requested * Removing includeDeleted parameter from GetChannelByName and GetChannelByNameForTeam * Back to ViewArchivedChannels config * Fixing tests * Reverting GetChannelByName parameter * Add include deleted parameter on GetChannel functions in plugins api * Fixing tests
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
65cd447a61
Коммит
5872bf9c2f
@@ -638,8 +638,9 @@ func (a *App) DeletePostFiles(post *model.Post) {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) SearchPostsInTeam(terms string, userId string, teamId string, isOrSearch bool) (*model.PostSearchResults, *model.AppError) {
|
||||
func (a *App) SearchPostsInTeam(terms string, userId string, teamId string, isOrSearch bool, includeDeletedChannels bool) (*model.PostSearchResults, *model.AppError) {
|
||||
paramsList := model.ParseSearchParams(terms)
|
||||
includeDeleted := includeDeletedChannels && *a.Config().TeamSettings.ViewArchivedChannels
|
||||
|
||||
esInterface := a.Elasticsearch
|
||||
if license := a.License(); esInterface != nil && *a.Config().ElasticsearchSettings.EnableSearching && license != nil && *license.Features.Elasticsearch {
|
||||
@@ -651,7 +652,7 @@ func (a *App) SearchPostsInTeam(terms string, userId string, teamId string, isOr
|
||||
if params.Terms != "*" {
|
||||
// Convert channel names to channel IDs
|
||||
for idx, channelName := range params.InChannels {
|
||||
if channel, err := a.GetChannelByName(channelName, teamId); err != nil {
|
||||
if channel, err := a.GetChannelByName(channelName, teamId, includeDeleted); err != nil {
|
||||
mlog.Error(fmt.Sprint(err))
|
||||
} else {
|
||||
params.InChannels[idx] = channel.Id
|
||||
@@ -677,7 +678,7 @@ func (a *App) SearchPostsInTeam(terms string, userId string, teamId string, isOr
|
||||
}
|
||||
|
||||
// We only allow the user to search in channels they are a member of.
|
||||
userChannels, err := a.GetChannelsForUser(teamId, userId)
|
||||
userChannels, err := a.GetChannelsForUser(teamId, userId, includeDeleted)
|
||||
if err != nil {
|
||||
mlog.Error(fmt.Sprint(err))
|
||||
return nil, err
|
||||
@@ -710,6 +711,7 @@ func (a *App) SearchPostsInTeam(terms string, userId string, teamId string, isOr
|
||||
channels := []store.StoreChannel{}
|
||||
|
||||
for _, params := range paramsList {
|
||||
params.IncludeDeletedChannels = includeDeleted
|
||||
params.OrTerms = isOrSearch
|
||||
// don't allow users to search for everything
|
||||
if params.Terms != "*" {
|
||||
|
||||
Ссылка в новой задаче
Block a user