Consistent error wrapping (#30600)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
64ff2434ee
Коммит
354d7aeb72
@@ -1552,7 +1552,7 @@ func (a *App) addUserToChannel(c request.CTX, user *model.User, channel *model.C
|
||||
if channel.IsGroupConstrained() {
|
||||
nonMembers, err := a.FilterNonGroupChannelMembers([]string{user.Id}, channel)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("addUserToChannel", "api.channel.add_user_to_channel.type.app_error", nil, "", http.StatusInternalServerError)
|
||||
return nil, model.NewAppError("addUserToChannel", "api.channel.add_user_to_channel.type.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
if len(nonMembers) > 0 {
|
||||
return nil, model.NewAppError("addUserToChannel", "api.channel.add_members.user_denied", map[string]any{"UserIDs": nonMembers}, "", http.StatusBadRequest)
|
||||
|
||||
@@ -241,7 +241,7 @@ func (a *App) GetMultipleEmojiByName(c request.CTX, names []string) ([]*model.Em
|
||||
|
||||
emoji, err := a.Srv().Store().Emoji().GetMultipleByName(c, names)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetMultipleEmojiByName", "app.emoji.get_by_name.app_error", nil, fmt.Sprintf("names=%v, %v", names, err.Error()), http.StatusInternalServerError)
|
||||
return nil, model.NewAppError("GetMultipleEmojiByName", "app.emoji.get_by_name.app_error", nil, fmt.Sprintf("names=%v", names), http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
return emoji, nil
|
||||
@@ -279,7 +279,7 @@ func (a *App) SearchEmoji(c request.CTX, name string, prefixOnly bool, limit int
|
||||
|
||||
list, err := a.Srv().Store().Emoji().Search(name, prefixOnly, limit)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SearchEmoji", "app.emoji.get_by_name.app_error", nil, "name="+name+", "+err.Error(), http.StatusInternalServerError)
|
||||
return nil, model.NewAppError("SearchEmoji", "app.emoji.get_by_name.app_error", nil, "name="+name, http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
return list, nil
|
||||
|
||||
@@ -123,7 +123,7 @@ func (a *App) BulkExport(ctx request.CTX, writer io.Writer, outPath string, job
|
||||
writer, err = zipWr.Create("import.jsonl")
|
||||
if err != nil {
|
||||
return model.NewAppError("BulkExport", "app.export.zip_create.error",
|
||||
nil, "err="+err.Error(), http.StatusInternalServerError)
|
||||
nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ func (a *App) BulkExport(ctx request.CTX, writer io.Writer, outPath string, job
|
||||
_, err := warningsFile.Write([]byte(warning + "\n"))
|
||||
if err != nil {
|
||||
return model.NewAppError("BulkExport", "app.export.zip_create.error",
|
||||
nil, "err="+err.Error(), http.StatusInternalServerError)
|
||||
nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
}
|
||||
updateJobProgress(ctx.Logger(), a.Srv().Store(), job, "num_warnings", len(warnings))
|
||||
@@ -897,7 +897,7 @@ func (a *App) exportCustomEmoji(rctx request.CTX, job *model.Job, writer io.Writ
|
||||
if exportFiles {
|
||||
if _, err := os.Stat(pathToDir); os.IsNotExist(err) {
|
||||
if err := os.Mkdir(pathToDir, os.ModePerm); err != nil {
|
||||
return nil, model.NewAppError("BulkExport", "app.export.export_custom_emoji.mkdir.error", nil, "err="+err.Error(), http.StatusBadRequest)
|
||||
return nil, model.NewAppError("BulkExport", "app.export.export_custom_emoji.mkdir.error", nil, "", http.StatusBadRequest).Wrap(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -907,7 +907,7 @@ func (a *App) exportCustomEmoji(rctx request.CTX, job *model.Job, writer io.Writ
|
||||
if exportFiles {
|
||||
err := a.copyEmojiImages(rctx, emoji.Id, emojiImagePath, pathToDir)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("BulkExport", "app.export.export_custom_emoji.copy_emoji_images.error", nil, "err="+err.Error(), http.StatusBadRequest)
|
||||
return nil, model.NewAppError("BulkExport", "app.export.export_custom_emoji.copy_emoji_images.error", nil, "", http.StatusBadRequest).Wrap(err)
|
||||
}
|
||||
} else {
|
||||
filePath = filepath.Join("emoji", emoji.Id, "image")
|
||||
@@ -1212,24 +1212,24 @@ func (a *App) exportFile(rctx request.CTX, outPath, filePath string, zipWr *zip.
|
||||
})
|
||||
if err != nil {
|
||||
return model.NewAppError("exportFileAttachment", "app.export.export_attachment.zip_create_header.error",
|
||||
nil, "err="+err.Error(), http.StatusInternalServerError)
|
||||
nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
if _, err = io.Copy(wr, rd); err != nil {
|
||||
return model.NewAppError("exportFileAttachment", "app.export.export_attachment.copy_file.error",
|
||||
nil, "err="+err.Error(), http.StatusInternalServerError)
|
||||
nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
} else {
|
||||
filePath = filepath.Join(outPath, model.ExportDataDir, filePath)
|
||||
if err := os.MkdirAll(filepath.Dir(filePath), 0700); err != nil {
|
||||
return model.NewAppError("exportFileAttachment", "app.export.export_attachment.mkdirall.error",
|
||||
nil, "err="+err.Error(), http.StatusInternalServerError)
|
||||
nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
file, err := os.Create(filePath)
|
||||
if err != nil {
|
||||
return model.NewAppError("exportFileAttachment", "app.export.export_attachment.create_file.error",
|
||||
nil, "err="+err.Error(), http.StatusInternalServerError)
|
||||
nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
defer func() {
|
||||
if err = file.Close(); err != nil {
|
||||
@@ -1239,7 +1239,7 @@ func (a *App) exportFile(rctx request.CTX, outPath, filePath string, zipWr *zip.
|
||||
|
||||
if _, err = io.Copy(file, rd); err != nil {
|
||||
return model.NewAppError("exportFileAttachment", "app.export.export_attachment.copy_file.error",
|
||||
nil, "err="+err.Error(), http.StatusInternalServerError)
|
||||
nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1278,7 +1278,7 @@ func (a *App) GeneratePresignURLForExport(name string) (*model.PresignURLRespons
|
||||
p := path.Join(*a.Config().ExportSettings.Directory, filepath.Base(name))
|
||||
found, err := b.FileExists(p)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GeneratePresignURLForExport", "app.eport.generate_presigned_url.fileexist.app_error", nil, "", http.StatusInternalServerError)
|
||||
return nil, model.NewAppError("GeneratePresignURLForExport", "app.eport.generate_presigned_url.fileexist.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
if !found {
|
||||
return nil, model.NewAppError("GeneratePresignURLForExport", "app.eport.generate_presigned_url.notfound.app_error", nil, "", http.StatusInternalServerError)
|
||||
@@ -1286,7 +1286,7 @@ func (a *App) GeneratePresignURLForExport(name string) (*model.PresignURLRespons
|
||||
|
||||
link, exp, err := backend.GeneratePublicLink(p)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GeneratePresignURLForExport", "app.eport.generate_presigned_url.link.app_error", nil, "", http.StatusInternalServerError)
|
||||
return nil, model.NewAppError("GeneratePresignURLForExport", "app.eport.generate_presigned_url.link.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
return &model.PresignURLResponse{
|
||||
|
||||
@@ -891,7 +891,7 @@ func (t *UploadFileTask) preprocessImage() *model.AppError {
|
||||
t.fileinfo.Height = cfg.Height
|
||||
|
||||
if err = checkImageResolutionLimit(cfg.Width, cfg.Height, t.maxImageRes); err != nil {
|
||||
return t.newAppError("api.file.upload_file.large_image_detailed.app_error", http.StatusBadRequest)
|
||||
return t.newAppError("api.file.upload_file.large_image_detailed.app_error", http.StatusBadRequest).Wrap(err)
|
||||
}
|
||||
|
||||
t.fileinfo.HasPreviewImage = true
|
||||
|
||||
@@ -961,7 +961,7 @@ func (a *App) importProfileImage(rctx request.CTX, userID string, data *imports.
|
||||
|
||||
if file != nil {
|
||||
if limitErr := checkImageLimits(file, *a.Config().FileSettings.MaxImageResolution); limitErr != nil {
|
||||
return model.NewAppError("SetProfileImage", "api.user.upload_profile_user.check_image_limits.app_error", nil, "", http.StatusBadRequest)
|
||||
return model.NewAppError("SetProfileImage", "api.user.upload_profile_user.check_image_limits.app_error", nil, "", http.StatusBadRequest).Wrap(limitErr)
|
||||
}
|
||||
if err := a.SetProfileImageFromFile(rctx, userID, file); err != nil {
|
||||
rctx.Logger().Warn("Unable to set the profile image from a file.", mlog.Err(err))
|
||||
@@ -1613,7 +1613,7 @@ func (a *App) importAttachment(rctx request.CTX, data *imports.AttachmentImportD
|
||||
if post.Id != "" {
|
||||
oldFiles, err := a.Srv().Store().FileInfo().GetForPost(post.Id, true, false, true)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("BulkImport", "app.import.attachment.file_upload.error", map[string]any{"FilePath": *data.Path}, "", http.StatusBadRequest)
|
||||
return nil, model.NewAppError("BulkImport", "app.import.attachment.file_upload.error", map[string]any{"FilePath": *data.Path}, "", http.StatusBadRequest).Wrap(err)
|
||||
}
|
||||
for _, oldFile := range oldFiles {
|
||||
if oldFile.Name != path.Base(name) || oldFile.Size != fileSize {
|
||||
@@ -1622,7 +1622,7 @@ func (a *App) importAttachment(rctx request.CTX, data *imports.AttachmentImportD
|
||||
|
||||
oldFileReader, appErr := a.FileReader(oldFile.Path)
|
||||
if appErr != nil {
|
||||
return nil, model.NewAppError("BulkImport", "app.import.attachment.file_upload.error", map[string]any{"FilePath": *data.Path}, "", http.StatusBadRequest)
|
||||
return nil, model.NewAppError("BulkImport", "app.import.attachment.file_upload.error", map[string]any{"FilePath": *data.Path}, "", http.StatusBadRequest).Wrap(appErr)
|
||||
}
|
||||
defer oldFileReader.Close()
|
||||
|
||||
@@ -2564,7 +2564,7 @@ func (a *App) importEmoji(rctx request.CTX, data *imports.EmojiImportData, dryRu
|
||||
file, err = os.Open(*data.Image)
|
||||
}
|
||||
if err != nil {
|
||||
return model.NewAppError("BulkImport", "app.import.emoji.bad_file.error", map[string]any{"EmojiName": *data.Name}, "", http.StatusBadRequest)
|
||||
return model.NewAppError("BulkImport", "app.import.emoji.bad_file.error", map[string]any{"EmojiName": *data.Name}, "", http.StatusBadRequest).Wrap(err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
|
||||
@@ -343,7 +343,7 @@ func (a *App) DoActionRequest(c request.CTX, rawURL string, body []byte) (*http.
|
||||
|
||||
resp, httpErr := httpClient.Do(req)
|
||||
if httpErr != nil {
|
||||
return nil, model.NewAppError("DoActionRequest", "api.post.do_action.action_integration.app_error", nil, "err="+httpErr.Error(), http.StatusBadRequest)
|
||||
return nil, model.NewAppError("DoActionRequest", "api.post.do_action.action_integration.app_error", nil, "", http.StatusBadRequest).Wrap(httpErr)
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
@@ -384,7 +384,7 @@ func (ch *Channels) doPluginRequest(c request.CTX, method, rawURL string, values
|
||||
rawURL = strings.TrimPrefix(rawURL, "/")
|
||||
inURL, err := url.Parse(rawURL)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("doPluginRequest", "api.post.do_action.action_integration.app_error", nil, "err="+err.Error(), http.StatusBadRequest)
|
||||
return nil, model.NewAppError("doPluginRequest", "api.post.do_action.action_integration.app_error", nil, "", http.StatusBadRequest).Wrap(err)
|
||||
}
|
||||
result := strings.Split(inURL.Path, "/")
|
||||
if len(result) < 2 {
|
||||
@@ -399,7 +399,7 @@ func (ch *Channels) doPluginRequest(c request.CTX, method, rawURL string, values
|
||||
|
||||
base, err := url.Parse(path)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("doPluginRequest", "api.post.do_action.action_integration.app_error", nil, "err="+err.Error(), http.StatusBadRequest)
|
||||
return nil, model.NewAppError("doPluginRequest", "api.post.do_action.action_integration.app_error", nil, "", http.StatusBadRequest).Wrap(err)
|
||||
}
|
||||
|
||||
// merge the rawQuery params (if any) with the function's provided values
|
||||
@@ -421,7 +421,7 @@ func (ch *Channels) doPluginRequest(c request.CTX, method, rawURL string, values
|
||||
w := &LocalResponseWriter{}
|
||||
r, err := http.NewRequest(method, base.String(), bytes.NewReader(body))
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("doPluginRequest", "api.post.do_action.action_integration.app_error", nil, "err="+err.Error(), http.StatusBadRequest)
|
||||
return nil, model.NewAppError("doPluginRequest", "api.post.do_action.action_integration.app_error", nil, "", http.StatusBadRequest).Wrap(err)
|
||||
}
|
||||
r.Header.Set("Mattermost-User-Id", c.Session().UserId)
|
||||
r.Header.Set(model.HeaderAuth, "Bearer "+c.Session().Token)
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -68,7 +67,7 @@ func TestPostActionInvalidURL(t *testing.T) {
|
||||
|
||||
_, err = th.App.DoPostActionWithCookie(th.Context, post.Id, attachments[0].Actions[0].Id, th.BasicUser.Id, "", nil)
|
||||
require.NotNil(t, err)
|
||||
require.True(t, strings.Contains(err.Error(), "missing protocol scheme"))
|
||||
assert.ErrorContains(t, err, "missing protocol scheme")
|
||||
}
|
||||
|
||||
func TestPostActionEmptyResponse(t *testing.T) {
|
||||
@@ -168,7 +167,7 @@ func TestPostActionEmptyResponse(t *testing.T) {
|
||||
|
||||
_, err = th.App.DoPostActionWithCookie(th.Context, post.Id, attachments[0].Actions[0].Id, th.BasicUser.Id, "", nil)
|
||||
require.NotNil(t, err)
|
||||
assert.Contains(t, err.DetailedError, "context deadline exceeded")
|
||||
assert.ErrorContains(t, err, "context deadline exceeded")
|
||||
})
|
||||
}
|
||||
|
||||
@@ -331,7 +330,7 @@ func TestPostAction(t *testing.T) {
|
||||
|
||||
_, err = th.App.DoPostActionWithCookie(th.Context, post.Id, attachments[0].Actions[0].Id, th.BasicUser.Id, "", nil)
|
||||
require.NotNil(t, err)
|
||||
require.True(t, strings.Contains(err.Error(), "address forbidden"))
|
||||
assert.ErrorContains(t, err, "address forbidden")
|
||||
|
||||
interactivePostPlugin := model.Post{
|
||||
Message: "Interactive post",
|
||||
@@ -417,7 +416,7 @@ func TestPostAction(t *testing.T) {
|
||||
|
||||
_, err = th.App.DoPostActionWithCookie(th.Context, postSiteURL.Id, attachmentsSiteURL[0].Actions[0].Id, th.BasicUser.Id, "", nil)
|
||||
require.NotNil(t, err)
|
||||
require.False(t, strings.Contains(err.Error(), "address forbidden"))
|
||||
assert.ErrorContains(t, err, "connection refused")
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.SiteURL = ts.URL + "/subpath"
|
||||
|
||||
@@ -247,7 +247,7 @@ func (a *App) GetOAuthAccessTokenForImplicitFlow(c request.CTX, userID string, a
|
||||
|
||||
oauthApp, err := a.GetOAuthApp(authRequest.ClientId)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.credentials.app_error", nil, "", http.StatusNotFound)
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.credentials.app_error", nil, "", http.StatusNotFound).Wrap(err)
|
||||
}
|
||||
|
||||
user, err := a.GetUser(userID)
|
||||
@@ -263,7 +263,7 @@ func (a *App) GetOAuthAccessTokenForImplicitFlow(c request.CTX, userID string, a
|
||||
accessData := &model.AccessData{ClientId: authRequest.ClientId, UserId: user.Id, Token: session.Token, RefreshToken: "", RedirectUri: authRequest.RedirectURI, ExpiresAt: session.ExpiresAt, Scope: authRequest.Scope}
|
||||
|
||||
if _, err := a.Srv().Store().OAuth().SaveAccessData(accessData); err != nil {
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.internal_saving.app_error", nil, "", http.StatusInternalServerError)
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.internal_saving.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
return session, nil
|
||||
@@ -276,7 +276,7 @@ func (a *App) GetOAuthAccessTokenForCodeFlow(c request.CTX, clientId, grantType,
|
||||
|
||||
oauthApp, nErr := a.Srv().Store().OAuth().GetApp(clientId)
|
||||
if nErr != nil {
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.credentials.app_error", nil, "", http.StatusNotFound)
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.credentials.app_error", nil, "", http.StatusNotFound).Wrap(nErr)
|
||||
}
|
||||
|
||||
if oauthApp.ClientSecret != secret {
|
||||
@@ -290,7 +290,7 @@ func (a *App) GetOAuthAccessTokenForCodeFlow(c request.CTX, clientId, grantType,
|
||||
var authData *model.AuthData
|
||||
authData, nErr = a.Srv().Store().OAuth().GetAuthData(code)
|
||||
if nErr != nil {
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.expired_code.app_error", nil, "", http.StatusBadRequest)
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.expired_code.app_error", nil, "", http.StatusBadRequest).Wrap(nErr)
|
||||
}
|
||||
|
||||
if authData.IsExpired() {
|
||||
@@ -306,7 +306,7 @@ func (a *App) GetOAuthAccessTokenForCodeFlow(c request.CTX, clientId, grantType,
|
||||
|
||||
user, nErr = a.Srv().Store().User().Get(context.Background(), authData.UserId)
|
||||
if nErr != nil {
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.internal_user.app_error", nil, "", http.StatusNotFound)
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.internal_user.app_error", nil, "", http.StatusNotFound).Wrap(nErr)
|
||||
}
|
||||
|
||||
if user.DeleteAt != 0 {
|
||||
@@ -315,7 +315,7 @@ func (a *App) GetOAuthAccessTokenForCodeFlow(c request.CTX, clientId, grantType,
|
||||
|
||||
accessData, nErr = a.Srv().Store().OAuth().GetPreviousAccessData(user.Id, clientId)
|
||||
if nErr != nil {
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.internal.app_error", nil, "", http.StatusBadRequest)
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.internal.app_error", nil, "", http.StatusBadRequest).Wrap(nErr)
|
||||
}
|
||||
|
||||
if accessData != nil {
|
||||
@@ -346,7 +346,7 @@ func (a *App) GetOAuthAccessTokenForCodeFlow(c request.CTX, clientId, grantType,
|
||||
accessData = &model.AccessData{ClientId: clientId, UserId: user.Id, Token: session.Token, RefreshToken: model.NewId(), RedirectUri: redirectURI, ExpiresAt: session.ExpiresAt, Scope: authData.Scope}
|
||||
|
||||
if _, nErr = a.Srv().Store().OAuth().SaveAccessData(accessData); nErr != nil {
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.internal_saving.app_error", nil, "", http.StatusInternalServerError)
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.internal_saving.app_error", nil, "", http.StatusInternalServerError).Wrap(nErr)
|
||||
}
|
||||
|
||||
accessRsp = &model.AccessResponse{
|
||||
@@ -364,12 +364,12 @@ func (a *App) GetOAuthAccessTokenForCodeFlow(c request.CTX, clientId, grantType,
|
||||
// When grantType is refresh_token
|
||||
accessData, nErr = a.Srv().Store().OAuth().GetAccessDataByRefreshToken(refreshToken)
|
||||
if nErr != nil {
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.refresh_token.app_error", nil, "", http.StatusNotFound)
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.refresh_token.app_error", nil, "", http.StatusNotFound).Wrap(nErr)
|
||||
}
|
||||
|
||||
user, nErr := a.Srv().Store().User().Get(context.Background(), accessData.UserId)
|
||||
if nErr != nil {
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.internal_user.app_error", nil, "", http.StatusNotFound)
|
||||
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.internal_user.app_error", nil, "", http.StatusNotFound).Wrap(nErr)
|
||||
}
|
||||
|
||||
access, err := a.newSessionUpdateToken(c, oauthApp, accessData, user)
|
||||
@@ -400,7 +400,7 @@ func (a *App) newSession(c request.CTX, app *model.OAuthApp, user *model.User) (
|
||||
|
||||
session, err := a.Srv().Store().Session().Save(c, session)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("newSession", "api.oauth.get_access_token.internal_session.app_error", nil, "", http.StatusInternalServerError)
|
||||
return nil, model.NewAppError("newSession", "api.oauth.get_access_token.internal_session.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
a.ch.srv.platform.AddSessionToCache(session)
|
||||
@@ -424,7 +424,7 @@ func (a *App) newSessionUpdateToken(c request.CTX, app *model.OAuthApp, accessDa
|
||||
accessData.ExpiresAt = session.ExpiresAt
|
||||
|
||||
if _, err := a.Srv().Store().OAuth().UpdateAccessData(accessData); err != nil {
|
||||
return nil, model.NewAppError("newSessionUpdateToken", "web.get_access_token.internal_saving.app_error", nil, "", http.StatusInternalServerError)
|
||||
return nil, model.NewAppError("newSessionUpdateToken", "web.get_access_token.internal_saving.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
accessRsp := &model.AccessResponse{
|
||||
AccessToken: session.Token,
|
||||
|
||||
@@ -666,91 +666,91 @@ func (api *PluginAPI) GetGroupsForUser(userID string) ([]*model.Group, *model.Ap
|
||||
|
||||
func (api *PluginAPI) UpsertGroupMember(groupID string, userID string) (*model.GroupMember, *model.AppError) {
|
||||
if err := api.checkLDAPLicense(); err != nil {
|
||||
return nil, model.NewAppError("UpsertGroupMember", "app.group.license_error", nil, err.Error(), http.StatusForbidden)
|
||||
return nil, model.NewAppError("UpsertGroupMember", "app.group.license_error", nil, "", http.StatusForbidden).Wrap(err)
|
||||
}
|
||||
return api.app.UpsertGroupMember(groupID, userID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) UpsertGroupMembers(groupID string, userIDs []string) ([]*model.GroupMember, *model.AppError) {
|
||||
if err := api.checkLDAPLicense(); err != nil {
|
||||
return nil, model.NewAppError("UpsertGroupMembers", "app.group.license_error", nil, err.Error(), http.StatusForbidden)
|
||||
return nil, model.NewAppError("UpsertGroupMembers", "app.group.license_error", nil, "", http.StatusForbidden).Wrap(err)
|
||||
}
|
||||
return api.app.UpsertGroupMembers(groupID, userIDs)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetGroupByRemoteID(remoteID string, groupSource model.GroupSource) (*model.Group, *model.AppError) {
|
||||
if err := api.checkLDAPLicense(); err != nil {
|
||||
return nil, model.NewAppError("GetGroupByRemoteID", "app.group.license_error", nil, err.Error(), http.StatusForbidden)
|
||||
return nil, model.NewAppError("GetGroupByRemoteID", "app.group.license_error", nil, "", http.StatusForbidden).Wrap(err)
|
||||
}
|
||||
return api.app.GetGroupByRemoteID(remoteID, groupSource)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) CreateGroup(group *model.Group) (*model.Group, *model.AppError) {
|
||||
if err := api.checkLDAPLicense(); err != nil {
|
||||
return nil, model.NewAppError("CreateGroup", "app.group.license_error", nil, err.Error(), http.StatusForbidden)
|
||||
return nil, model.NewAppError("CreateGroup", "app.group.license_error", nil, "", http.StatusForbidden).Wrap(err)
|
||||
}
|
||||
return api.app.CreateGroup(group)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) UpdateGroup(group *model.Group) (*model.Group, *model.AppError) {
|
||||
if err := api.checkLDAPLicense(); err != nil {
|
||||
return nil, model.NewAppError("UpdateGroup", "app.group.license_error", nil, err.Error(), http.StatusForbidden)
|
||||
return nil, model.NewAppError("UpdateGroup", "app.group.license_error", nil, "", http.StatusForbidden).Wrap(err)
|
||||
}
|
||||
return api.app.UpdateGroup(group)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) DeleteGroup(groupID string) (*model.Group, *model.AppError) {
|
||||
if err := api.checkLDAPLicense(); err != nil {
|
||||
return nil, model.NewAppError("DeleteGroup", "app.group.license_error", nil, err.Error(), http.StatusForbidden)
|
||||
return nil, model.NewAppError("DeleteGroup", "app.group.license_error", nil, "", http.StatusForbidden).Wrap(err)
|
||||
}
|
||||
return api.app.DeleteGroup(groupID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) RestoreGroup(groupID string) (*model.Group, *model.AppError) {
|
||||
if err := api.checkLDAPLicense(); err != nil {
|
||||
return nil, model.NewAppError("RestoreGroup", "app.group.license_error", nil, err.Error(), http.StatusForbidden)
|
||||
return nil, model.NewAppError("RestoreGroup", "app.group.license_error", nil, "", http.StatusForbidden).Wrap(err)
|
||||
}
|
||||
return api.app.RestoreGroup(groupID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) DeleteGroupMember(groupID string, userID string) (*model.GroupMember, *model.AppError) {
|
||||
if err := api.checkLDAPLicense(); err != nil {
|
||||
return nil, model.NewAppError("DeleteGroupMember", "app.group.license_error", nil, err.Error(), http.StatusForbidden)
|
||||
return nil, model.NewAppError("DeleteGroupMember", "app.group.license_error", nil, "", http.StatusForbidden).Wrap(err)
|
||||
}
|
||||
return api.app.DeleteGroupMember(groupID, userID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetGroupSyncable(groupID string, syncableID string, syncableType model.GroupSyncableType) (*model.GroupSyncable, *model.AppError) {
|
||||
if err := api.checkLDAPLicense(); err != nil {
|
||||
return nil, model.NewAppError("GetGroupSyncable", "app.group.license_error", nil, err.Error(), http.StatusForbidden)
|
||||
return nil, model.NewAppError("GetGroupSyncable", "app.group.license_error", nil, "", http.StatusForbidden).Wrap(err)
|
||||
}
|
||||
return api.app.GetGroupSyncable(groupID, syncableID, syncableType)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetGroupSyncables(groupID string, syncableType model.GroupSyncableType) ([]*model.GroupSyncable, *model.AppError) {
|
||||
if err := api.checkLDAPLicense(); err != nil {
|
||||
return nil, model.NewAppError("GetGroupSyncables", "app.group.license_error", nil, err.Error(), http.StatusForbidden)
|
||||
return nil, model.NewAppError("GetGroupSyncables", "app.group.license_error", nil, "", http.StatusForbidden).Wrap(err)
|
||||
}
|
||||
return api.app.GetGroupSyncables(groupID, syncableType)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) UpsertGroupSyncable(groupSyncable *model.GroupSyncable) (*model.GroupSyncable, *model.AppError) {
|
||||
if err := api.checkLDAPLicense(); err != nil {
|
||||
return nil, model.NewAppError("UpsertGroupSyncable", "app.group.license_error", nil, err.Error(), http.StatusForbidden)
|
||||
return nil, model.NewAppError("UpsertGroupSyncable", "app.group.license_error", nil, "", http.StatusForbidden).Wrap(err)
|
||||
}
|
||||
return api.app.UpsertGroupSyncable(groupSyncable)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) UpdateGroupSyncable(groupSyncable *model.GroupSyncable) (*model.GroupSyncable, *model.AppError) {
|
||||
if err := api.checkLDAPLicense(); err != nil {
|
||||
return nil, model.NewAppError("UpdateGroupSyncable", "app.group.license_error", nil, err.Error(), http.StatusForbidden)
|
||||
return nil, model.NewAppError("UpdateGroupSyncable", "app.group.license_error", nil, "", http.StatusForbidden).Wrap(err)
|
||||
}
|
||||
return api.app.UpdateGroupSyncable(groupSyncable)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) DeleteGroupSyncable(groupID string, syncableID string, syncableType model.GroupSyncableType) (*model.GroupSyncable, *model.AppError) {
|
||||
if err := api.checkLDAPLicense(); err != nil {
|
||||
return nil, model.NewAppError("DeleteGroupSyncable", "app.group.license_error", nil, err.Error(), http.StatusForbidden)
|
||||
return nil, model.NewAppError("DeleteGroupSyncable", "app.group.license_error", nil, "", http.StatusForbidden).Wrap(err)
|
||||
}
|
||||
return api.app.DeleteGroupSyncable(groupID, syncableID, syncableType)
|
||||
}
|
||||
@@ -1030,7 +1030,7 @@ func (api *PluginAPI) InstallPlugin(file io.Reader, replace bool) (*model.Manife
|
||||
|
||||
fileBuffer, err := io.ReadAll(file)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("InstallPlugin", "api.plugin.upload.file.app_error", nil, "", http.StatusBadRequest)
|
||||
return nil, model.NewAppError("InstallPlugin", "api.plugin.upload.file.app_error", nil, "", http.StatusBadRequest).Wrap(err)
|
||||
}
|
||||
|
||||
return api.app.InstallPlugin(bytes.NewReader(fileBuffer), replace)
|
||||
@@ -1453,7 +1453,7 @@ func (api *PluginAPI) GetPluginID() string {
|
||||
|
||||
func (api *PluginAPI) GetGroups(page, perPage int, opts model.GroupSearchOpts, viewRestrictions *model.ViewUsersRestrictions) ([]*model.Group, *model.AppError) {
|
||||
if err := api.checkLDAPLicense(); err != nil {
|
||||
return nil, model.NewAppError("GetGroups", "app.group.license_error", nil, err.Error(), http.StatusForbidden)
|
||||
return nil, model.NewAppError("GetGroups", "app.group.license_error", nil, "", http.StatusForbidden).Wrap(err)
|
||||
}
|
||||
return api.app.GetGroups(page, perPage, opts, viewRestrictions)
|
||||
}
|
||||
|
||||
@@ -144,12 +144,12 @@ func (a *App) tryExecutePluginCommand(c request.CTX, args *model.CommandArgs) (*
|
||||
|
||||
// Checking if plugin is working or not
|
||||
if err := pluginsEnvironment.PerformHealthCheck(matched.PluginId); err != nil {
|
||||
return matched.Command, nil, model.NewAppError("ExecutePluginCommand", "model.plugin_command_error.error.app_error", map[string]any{"Command": trigger}, "err= Plugin has recently crashed: "+matched.PluginId, http.StatusInternalServerError)
|
||||
return matched.Command, nil, model.NewAppError("ExecutePluginCommand", "model.plugin_command_error.error.app_error", map[string]any{"Command": trigger}, "err= Plugin has recently crashed: "+matched.PluginId, http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
pluginHooks, err := pluginsEnvironment.HooksForPlugin(matched.PluginId)
|
||||
if err != nil {
|
||||
return matched.Command, nil, model.NewAppError("ExecutePluginCommand", "model.plugin_command.error.app_error", nil, "err="+err.Error(), http.StatusInternalServerError)
|
||||
return matched.Command, nil, model.NewAppError("ExecutePluginCommand", "model.plugin_command.error.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
for username, userID := range a.MentionsToTeamMembers(c, args.Command, args.TeamId) {
|
||||
|
||||
@@ -281,7 +281,7 @@ func (ch *Channels) InstallMarketplacePlugin(request *model.InstallMarketplacePl
|
||||
if prepackagedPlugin != nil {
|
||||
fileReader, err := os.Open(prepackagedPlugin.Path)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("InstallMarketplacePlugin", "app.plugin.install_marketplace_plugin.app_error", nil, fmt.Sprintf("failed to open prepackaged plugin %s: %s", prepackagedPlugin.Path, err.Error()), http.StatusInternalServerError)
|
||||
return nil, model.NewAppError("InstallMarketplacePlugin", "app.plugin.install_marketplace_plugin.app_error", nil, fmt.Sprintf("failed to open prepackaged plugin %s", prepackagedPlugin.Path), http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
defer fileReader.Close()
|
||||
|
||||
@@ -459,12 +459,12 @@ func (ch *Channels) installExtractedPlugin(manifest *model.Manifest, fromPluginD
|
||||
|
||||
version, err = semver.Parse(manifest.Version)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("installExtractedPlugin", "app.plugin.invalid_version.app_error", nil, "", http.StatusBadRequest)
|
||||
return nil, model.NewAppError("installExtractedPlugin", "app.plugin.invalid_version.app_error", nil, "", http.StatusBadRequest).Wrap(err)
|
||||
}
|
||||
|
||||
existingVersion, err = semver.Parse(existingManifest.Version)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("installExtractedPlugin", "app.plugin.invalid_version.app_error", nil, "", http.StatusInternalServerError)
|
||||
return nil, model.NewAppError("installExtractedPlugin", "app.plugin.invalid_version.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
if version.LTE(existingVersion) {
|
||||
@@ -476,7 +476,7 @@ func (ch *Channels) installExtractedPlugin(manifest *model.Manifest, fromPluginD
|
||||
// Otherwise remove the existing installation prior to installing below.
|
||||
logger.Info("Removing existing installation of plugin before local install", mlog.String("existing_version", existingManifest.Version))
|
||||
if err := ch.removePluginLocally(existingManifest.Id); err != nil {
|
||||
return nil, model.NewAppError("installExtractedPlugin", "app.plugin.install_id_failed_remove.app_error", nil, "", http.StatusInternalServerError)
|
||||
return nil, model.NewAppError("installExtractedPlugin", "app.plugin.install_id_failed_remove.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -277,7 +277,7 @@ func (a *App) CreatePost(c request.CTX, post *model.Post, channel *model.Channel
|
||||
if pchan != nil {
|
||||
result := <-pchan
|
||||
if result.NErr != nil {
|
||||
return nil, model.NewAppError("createPost", "api.post.create_post.root_id.app_error", nil, "", http.StatusBadRequest)
|
||||
return nil, model.NewAppError("createPost", "api.post.create_post.root_id.app_error", nil, "", http.StatusBadRequest).Wrap(result.NErr)
|
||||
}
|
||||
parentPostList = result.Data
|
||||
if len(parentPostList.Posts) == 0 || !parentPostList.IsChannelId(post.ChannelId) {
|
||||
@@ -2580,7 +2580,7 @@ func (a *App) CopyWranglerPostlist(c request.CTX, wpl *model.WranglerPostList, t
|
||||
func (a *App) MoveThread(c request.CTX, postID string, sourceChannelID, channelID string, user *model.User) *model.AppError {
|
||||
postListResponse, appErr := a.GetPostThread(postID, model.GetPostsOptions{}, user.Id)
|
||||
if appErr != nil {
|
||||
return model.NewAppError("getPostThread", "app.post.move_thread_command.error", nil, "postID="+postID+", "+"UserId="+user.Id+"", http.StatusBadRequest)
|
||||
return model.NewAppError("getPostThread", "app.post.move_thread_command.error", nil, "postID="+postID+", "+"UserId="+user.Id+"", http.StatusBadRequest).Wrap(appErr)
|
||||
}
|
||||
wpl := postListResponse.BuildWranglerPostList()
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ func (a *App) GetSamlMetadata(c request.CTX) (string, *model.AppError) {
|
||||
|
||||
result, err := a.Saml().GetMetadata(c)
|
||||
if err != nil {
|
||||
return "", model.NewAppError("GetSamlMetadata", "api.admin.saml.metadata.app_error", nil, "err="+err.Message, err.StatusCode)
|
||||
return "", model.NewAppError("GetSamlMetadata", "api.admin.saml.metadata.app_error", nil, "", err.StatusCode).Wrap(err)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ func (a *App) SaveScheduledPost(rctx request.CTX, scheduledPost *model.Scheduled
|
||||
|
||||
savedScheduledPost, err := a.Srv().Store().ScheduledPost().CreateScheduledPost(scheduledPost)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("App.ScheduledPost", "app.save_scheduled_post.save.app_error", map[string]any{"user_id": scheduledPost.UserId, "channel_id": scheduledPost.ChannelId}, "", http.StatusBadRequest)
|
||||
return nil, model.NewAppError("App.ScheduledPost", "app.save_scheduled_post.save.app_error", map[string]any{"user_id": scheduledPost.UserId, "channel_id": scheduledPost.ChannelId}, "", http.StatusBadRequest).Wrap(err)
|
||||
}
|
||||
|
||||
a.PublishScheduledPostEvent(rctx, model.WebsocketScheduledPostCreated, savedScheduledPost, connectionId)
|
||||
@@ -42,7 +42,7 @@ func (a *App) SaveScheduledPost(rctx request.CTX, scheduledPost *model.Scheduled
|
||||
func (a *App) GetUserTeamScheduledPosts(rctx request.CTX, userId, teamId string) ([]*model.ScheduledPost, *model.AppError) {
|
||||
scheduledPosts, err := a.Srv().Store().ScheduledPost().GetScheduledPostsForUser(userId, teamId)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("App.GetUserTeamScheduledPosts", "app.get_user_team_scheduled_posts.error", map[string]any{"user_id": userId, "team_id": teamId}, "", http.StatusInternalServerError)
|
||||
return nil, model.NewAppError("App.GetUserTeamScheduledPosts", "app.get_user_team_scheduled_posts.error", map[string]any{"user_id": userId, "team_id": teamId}, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
if scheduledPosts == nil {
|
||||
@@ -66,7 +66,7 @@ func (a *App) UpdateScheduledPost(rctx request.CTX, userId string, scheduledPost
|
||||
// validate the scheduled post belongs to the said user
|
||||
existingScheduledPost, err := a.Srv().Store().ScheduledPost().Get(scheduledPost.Id)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("app.UpdateScheduledPost", "app.update_scheduled_post.get_scheduled_post.error", map[string]any{"user_id": userId, "scheduled_post_id": scheduledPost.Id}, "", http.StatusInternalServerError)
|
||||
return nil, model.NewAppError("app.UpdateScheduledPost", "app.update_scheduled_post.get_scheduled_post.error", map[string]any{"user_id": userId, "scheduled_post_id": scheduledPost.Id}, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
if existingScheduledPost == nil {
|
||||
@@ -82,7 +82,7 @@ func (a *App) UpdateScheduledPost(rctx request.CTX, userId string, scheduledPost
|
||||
scheduledPost.RestoreNonUpdatableFields(existingScheduledPost)
|
||||
|
||||
if err := a.Srv().Store().ScheduledPost().UpdatedScheduledPost(scheduledPost); err != nil {
|
||||
return nil, model.NewAppError("app.UpdateScheduledPost", "app.update_scheduled_post.update.error", map[string]any{"user_id": userId, "scheduled_post_id": scheduledPost.Id}, "", http.StatusInternalServerError)
|
||||
return nil, model.NewAppError("app.UpdateScheduledPost", "app.update_scheduled_post.update.error", map[string]any{"user_id": userId, "scheduled_post_id": scheduledPost.Id}, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
a.PublishScheduledPostEvent(rctx, model.WebsocketScheduledPostUpdated, scheduledPost, connectionId)
|
||||
@@ -93,7 +93,7 @@ func (a *App) UpdateScheduledPost(rctx request.CTX, userId string, scheduledPost
|
||||
func (a *App) DeleteScheduledPost(rctx request.CTX, userId, scheduledPostId, connectionId string) (*model.ScheduledPost, *model.AppError) {
|
||||
scheduledPost, err := a.Srv().Store().ScheduledPost().Get(scheduledPostId)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("app.DeleteScheduledPost", "app.delete_scheduled_post.get_scheduled_post.error", map[string]any{"user_id": userId, "scheduled_post_id": scheduledPostId}, "", http.StatusInternalServerError)
|
||||
return nil, model.NewAppError("app.DeleteScheduledPost", "app.delete_scheduled_post.get_scheduled_post.error", map[string]any{"user_id": userId, "scheduled_post_id": scheduledPostId}, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
if scheduledPost == nil {
|
||||
@@ -105,7 +105,7 @@ func (a *App) DeleteScheduledPost(rctx request.CTX, userId, scheduledPostId, con
|
||||
}
|
||||
|
||||
if err := a.Srv().Store().ScheduledPost().PermanentlyDeleteScheduledPosts([]string{scheduledPostId}); err != nil {
|
||||
return nil, model.NewAppError("app.DeleteScheduledPost", "app.delete_scheduled_post.delete_error", map[string]any{"user_id": userId, "scheduled_post_id": scheduledPostId}, "", http.StatusInternalServerError)
|
||||
return nil, model.NewAppError("app.DeleteScheduledPost", "app.delete_scheduled_post.delete_error", map[string]any{"user_id": userId, "scheduled_post_id": scheduledPostId}, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
a.PublishScheduledPostEvent(rctx, model.WebsocketScheduledPostDeleted, scheduledPost, connectionId)
|
||||
|
||||
@@ -183,7 +183,11 @@ func (a *App) RemoveRecentCustomStatus(c request.CTX, userID string, status *mod
|
||||
return model.NewAppError("RemoveRecentCustomStatus", "api.unmarshal_error", nil, "", http.StatusBadRequest).Wrap(err)
|
||||
}
|
||||
|
||||
if ok, err := existingRCS.Contains(status); !ok || err != nil {
|
||||
ok, err := existingRCS.Contains(status)
|
||||
if err != nil {
|
||||
return model.NewAppError("RemoveRecentCustomStatus", "api.custom_status.recent_custom_statuses.delete.app_error", nil, "", http.StatusBadRequest).Wrap(err)
|
||||
}
|
||||
if !ok {
|
||||
return model.NewAppError("RemoveRecentCustomStatus", "api.custom_status.recent_custom_statuses.delete.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
|
||||
@@ -1874,7 +1874,7 @@ func (a *App) GetTeamIdFromQuery(rctx request.CTX, query url.Values) (string, *m
|
||||
if tokenID != "" {
|
||||
token, err := a.Srv().Store().Token().GetByToken(tokenID)
|
||||
if err != nil {
|
||||
return "", model.NewAppError("GetTeamIdFromQuery", "api.oauth.singup_with_oauth.invalid_link.app_error", nil, "", http.StatusBadRequest)
|
||||
return "", model.NewAppError("GetTeamIdFromQuery", "api.oauth.singup_with_oauth.invalid_link.app_error", nil, "", http.StatusBadRequest).Wrap(err)
|
||||
}
|
||||
|
||||
if token.Type != TokenTypeTeamInvitation && token.Type != TokenTypeGuestInvitation {
|
||||
|
||||
@@ -876,7 +876,7 @@ func (a *App) SetProfileImage(c request.CTX, userID string, imageData *multipart
|
||||
|
||||
func (a *App) SetProfileImageFromMultiPartFile(c request.CTX, userID string, file multipart.File) *model.AppError {
|
||||
if limitErr := checkImageLimits(file, *a.Config().FileSettings.MaxImageResolution); limitErr != nil {
|
||||
return model.NewAppError("SetProfileImage", "api.user.upload_profile_user.check_image_limits.app_error", nil, "", http.StatusBadRequest)
|
||||
return model.NewAppError("SetProfileImage", "api.user.upload_profile_user.check_image_limits.app_error", nil, "", http.StatusBadRequest).Wrap(limitErr)
|
||||
}
|
||||
|
||||
return a.SetProfileImageFromFile(c, userID, file)
|
||||
@@ -1593,7 +1593,7 @@ func (a *App) SendPasswordReset(rctx request.CTX, email string, siteURL string)
|
||||
|
||||
result, eErr := a.Srv().EmailService.SendPasswordResetEmail(user.Email, token, user.Locale, siteURL)
|
||||
if eErr != nil {
|
||||
return result, model.NewAppError("SendPasswordReset", "api.user.send_password_reset.send.app_error", nil, "err="+eErr.Error(), http.StatusInternalServerError)
|
||||
return result, model.NewAppError("SendPasswordReset", "api.user.send_password_reset.send.app_error", nil, "", http.StatusInternalServerError).Wrap(eErr)
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
||||
@@ -372,7 +372,7 @@ func (a *App) CreateWebhookPost(c request.CTX, userID string, channel *model.Cha
|
||||
|
||||
for _, split := range splits {
|
||||
if _, err = a.CreatePost(c, split, channel, model.CreatePostFlags{}); err != nil {
|
||||
return nil, model.NewAppError("CreateWebhookPost", "api.post.create_webhook_post.creating.app_error", nil, "err="+err.Message, http.StatusInternalServerError)
|
||||
return nil, model.NewAppError("CreateWebhookPost", "api.post.create_webhook_post.creating.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7940,8 +7940,8 @@ func (c *Client4) RestoreGroup(ctx context.Context, groupID string, etag string)
|
||||
}
|
||||
defer closeBody(r)
|
||||
var p Group
|
||||
if jsonErr := json.NewDecoder(r.Body).Decode(&p); jsonErr != nil {
|
||||
return nil, nil, NewAppError("DeleteGroup", "api.unmarshal_error", nil, jsonErr.Error(), http.StatusInternalServerError)
|
||||
if err := json.NewDecoder(r.Body).Decode(&p); err != nil {
|
||||
return nil, nil, NewAppError("DeleteGroup", "api.unmarshal_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
return &p, BuildResponse(r), nil
|
||||
}
|
||||
@@ -9241,8 +9241,8 @@ func (c *Client4) AcknowledgePost(ctx context.Context, postId, userId string) (*
|
||||
}
|
||||
defer closeBody(r)
|
||||
var ack *PostAcknowledgement
|
||||
if jsonErr := json.NewDecoder(r.Body).Decode(&ack); jsonErr != nil {
|
||||
return nil, nil, NewAppError("AcknowledgePost", "api.unmarshal_error", nil, jsonErr.Error(), http.StatusInternalServerError)
|
||||
if err := json.NewDecoder(r.Body).Decode(&ack); err != nil {
|
||||
return nil, nil, NewAppError("AcknowledgePost", "api.unmarshal_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
return ack, BuildResponse(r), nil
|
||||
}
|
||||
|
||||
@@ -4370,7 +4370,7 @@ func (s *ServiceSettings) isValid() *AppError {
|
||||
parent := filepath.Dir(*s.LocalModeSocketLocation)
|
||||
_, err := os.Stat(parent)
|
||||
if err != nil {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.local_mode_socket.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.local_mode_socket.app_error", nil, err.Error(), http.StatusBadRequest).Wrap(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user