Remove model.AppError from searchlayer/post_layer.go (#16452)

* Remove model.AppError from searchlayer/post_layer.go

* change nErr to err

* fix tautological condition

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
Mohammed Salman
2020-12-16 16:49:18 +03:00
committed by GitHub
parent eb7c4580f8
commit 6b7e261e06

View File

@@ -4,9 +4,6 @@
package searchlayer
import (
"errors"
"net/http"
"github.com/mattermost/mattermost-server/v5/mlog"
"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/services/searchengine"
@@ -137,17 +134,10 @@ func (s SearchPostStore) searchPostsInTeamForUserByEngine(engine searchengine.Se
}
// We only allow the user to search in channels they are a member of.
userChannels, nErr := s.rootStore.Channel().GetChannels(teamId, userId, paramsList[0].IncludeDeletedChannels, 0)
if nErr != nil {
mlog.Error("error getting channel for user", mlog.Err(nErr))
var nfErr *store.ErrNotFound
switch {
// TODO: This error key would go away once this store method is migrated to return plain errors
case errors.As(nErr, &nfErr):
return nil, model.NewAppError("searchPostsInTeamForUserByEngine", "app.channel.get_channels.not_found.app_error", nil, nfErr.Error(), http.StatusNotFound)
default:
return nil, model.NewAppError("searchPostsInTeamForUserByEngine", "app.channel.get_channels.get.app_error", nil, nErr.Error(), http.StatusInternalServerError)
}
userChannels, err2 := s.rootStore.Channel().GetChannels(teamId, userId, paramsList[0].IncludeDeletedChannels, 0)
if err2 != nil {
mlog.Error("error getting channel for user", mlog.Err(err2))
return nil, err2
}
postIds, matches, err := engine.SearchPosts(userChannels, paramsList, page, perPage)