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>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
eb7c4580f8
Коммит
6b7e261e06
@@ -4,9 +4,6 @@
|
|||||||
package searchlayer
|
package searchlayer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/mattermost/mattermost-server/v5/mlog"
|
"github.com/mattermost/mattermost-server/v5/mlog"
|
||||||
"github.com/mattermost/mattermost-server/v5/model"
|
"github.com/mattermost/mattermost-server/v5/model"
|
||||||
"github.com/mattermost/mattermost-server/v5/services/searchengine"
|
"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.
|
// 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)
|
userChannels, err2 := s.rootStore.Channel().GetChannels(teamId, userId, paramsList[0].IncludeDeletedChannels, 0)
|
||||||
if nErr != nil {
|
if err2 != nil {
|
||||||
mlog.Error("error getting channel for user", mlog.Err(nErr))
|
mlog.Error("error getting channel for user", mlog.Err(err2))
|
||||||
var nfErr *store.ErrNotFound
|
return nil, err2
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
postIds, matches, err := engine.SearchPosts(userChannels, paramsList, page, perPage)
|
postIds, matches, err := engine.SearchPosts(userChannels, paramsList, page, perPage)
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user