mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user