Migrate Get/GetFromMaster methods from ChannelStore to return error interface (#14688)
* Advances * Migration finished * Rename err to normalized error * fix imports * Renamed key * Renamed key * Suggestions * Fix i18n * Fix tests Co-authored-by: Jesús Espino <jespinog@gmail.com> Co-authored-by: Agniva De Sarker <agnivade@yahoo.co.in>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
60cc775cf6
Коммит
85a69d6112
@@ -5,6 +5,7 @@ package app
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -94,7 +95,13 @@ func (a *App) CreatePostAsUser(post *model.Post, currentSessionId string, setOnl
|
||||
func (a *App) CreatePostMissingChannel(post *model.Post, triggerWebhooks bool) (*model.Post, *model.AppError) {
|
||||
channel, err := a.Srv().Store.Channel().Get(post.ChannelId, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(err, &nfErr):
|
||||
return nil, model.NewAppError("CreatePostMissingChannel", "app.channel.get.existing.app_error", nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return nil, model.NewAppError("CreatePostMissingChannel", "app.channel.get.find.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
return a.CreatePost(post, channel, triggerWebhooks, true)
|
||||
|
||||
Ссылка в новой задаче
Block a user