From 6b7e261e06e9c7b8d2c268f50a08ba59b28524d1 Mon Sep 17 00:00:00 2001 From: Mohammed Salman Date: Wed, 16 Dec 2020 16:49:18 +0300 Subject: [PATCH] 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 --- store/searchlayer/post_layer.go | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/store/searchlayer/post_layer.go b/store/searchlayer/post_layer.go index ccddb6a310..d5550f13b8 100644 --- a/store/searchlayer/post_layer.go +++ b/store/searchlayer/post_layer.go @@ -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)