diff options
author | Martin Kraft <mkraft@users.noreply.github.com> | 2018-07-30 15:06:08 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-30 15:06:08 -0400 |
commit | 5872bf9c2f9b81c7aad761d40a6970f6267f1424 (patch) | |
tree | 2f850c0678f9fbd8979d41cb758503ca6cb1a2d7 /app/post.go | |
parent | 65cd447a61efa852da2c0e7db25f385c2436e236 (diff) | |
download | chat-5872bf9c2f9b81c7aad761d40a6970f6267f1424.tar.gz chat-5872bf9c2f9b81c7aad761d40a6970f6267f1424.tar.bz2 chat-5872bf9c2f9b81c7aad761d40a6970f6267f1424.zip |
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
Diffstat (limited to 'app/post.go')
-rw-r--r-- | app/post.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/app/post.go b/app/post.go index 0344d8f0d..8c44436aa 100644 --- a/app/post.go +++ b/app/post.go @@ -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 != "*" { |