Этот коммит содержится в:
Ben Schumacher
2025-04-09 11:38:36 +02:00
коммит произвёл GitHub
родитель 64ff2434ee
Коммит 354d7aeb72
20 изменённых файлов: 82 добавлений и 79 удалений

Просмотреть файл

@@ -1552,7 +1552,7 @@ func (a *App) addUserToChannel(c request.CTX, user *model.User, channel *model.C
if channel.IsGroupConstrained() { if channel.IsGroupConstrained() {
nonMembers, err := a.FilterNonGroupChannelMembers([]string{user.Id}, channel) nonMembers, err := a.FilterNonGroupChannelMembers([]string{user.Id}, channel)
if err != nil { 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 { if len(nonMembers) > 0 {
return nil, model.NewAppError("addUserToChannel", "api.channel.add_members.user_denied", map[string]any{"UserIDs": nonMembers}, "", http.StatusBadRequest) 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) emoji, err := a.Srv().Store().Emoji().GetMultipleByName(c, names)
if err != nil { 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 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) list, err := a.Srv().Store().Emoji().Search(name, prefixOnly, limit)
if err != nil { 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 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") writer, err = zipWr.Create("import.jsonl")
if err != nil { if err != nil {
return model.NewAppError("BulkExport", "app.export.zip_create.error", 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")) _, err := warningsFile.Write([]byte(warning + "\n"))
if err != nil { if err != nil {
return model.NewAppError("BulkExport", "app.export.zip_create.error", 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)) 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 exportFiles {
if _, err := os.Stat(pathToDir); os.IsNotExist(err) { if _, err := os.Stat(pathToDir); os.IsNotExist(err) {
if err := os.Mkdir(pathToDir, os.ModePerm); err != nil { 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 { if exportFiles {
err := a.copyEmojiImages(rctx, emoji.Id, emojiImagePath, pathToDir) err := a.copyEmojiImages(rctx, emoji.Id, emojiImagePath, pathToDir)
if err != nil { 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 { } else {
filePath = filepath.Join("emoji", emoji.Id, "image") 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 { if err != nil {
return model.NewAppError("exportFileAttachment", "app.export.export_attachment.zip_create_header.error", 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 { if _, err = io.Copy(wr, rd); err != nil {
return model.NewAppError("exportFileAttachment", "app.export.export_attachment.copy_file.error", return model.NewAppError("exportFileAttachment", "app.export.export_attachment.copy_file.error",
nil, "err="+err.Error(), http.StatusInternalServerError) nil, "", http.StatusInternalServerError).Wrap(err)
} }
} else { } else {
filePath = filepath.Join(outPath, model.ExportDataDir, filePath) filePath = filepath.Join(outPath, model.ExportDataDir, filePath)
if err := os.MkdirAll(filepath.Dir(filePath), 0700); err != nil { if err := os.MkdirAll(filepath.Dir(filePath), 0700); err != nil {
return model.NewAppError("exportFileAttachment", "app.export.export_attachment.mkdirall.error", 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) file, err := os.Create(filePath)
if err != nil { if err != nil {
return model.NewAppError("exportFileAttachment", "app.export.export_attachment.create_file.error", return model.NewAppError("exportFileAttachment", "app.export.export_attachment.create_file.error",
nil, "err="+err.Error(), http.StatusInternalServerError) nil, "", http.StatusInternalServerError).Wrap(err)
} }
defer func() { defer func() {
if err = file.Close(); err != nil { 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 { if _, err = io.Copy(file, rd); err != nil {
return model.NewAppError("exportFileAttachment", "app.export.export_attachment.copy_file.error", 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)) p := path.Join(*a.Config().ExportSettings.Directory, filepath.Base(name))
found, err := b.FileExists(p) found, err := b.FileExists(p)
if err != nil { 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 { if !found {
return nil, model.NewAppError("GeneratePresignURLForExport", "app.eport.generate_presigned_url.notfound.app_error", nil, "", http.StatusInternalServerError) 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) link, exp, err := backend.GeneratePublicLink(p)
if err != nil { 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{ return &model.PresignURLResponse{

Просмотреть файл

@@ -891,7 +891,7 @@ func (t *UploadFileTask) preprocessImage() *model.AppError {
t.fileinfo.Height = cfg.Height t.fileinfo.Height = cfg.Height
if err = checkImageResolutionLimit(cfg.Width, cfg.Height, t.maxImageRes); err != nil { 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 t.fileinfo.HasPreviewImage = true

Просмотреть файл

@@ -961,7 +961,7 @@ func (a *App) importProfileImage(rctx request.CTX, userID string, data *imports.
if file != nil { if file != nil {
if limitErr := checkImageLimits(file, *a.Config().FileSettings.MaxImageResolution); limitErr != 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 { if err := a.SetProfileImageFromFile(rctx, userID, file); err != nil {
rctx.Logger().Warn("Unable to set the profile image from a file.", mlog.Err(err)) 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 != "" { if post.Id != "" {
oldFiles, err := a.Srv().Store().FileInfo().GetForPost(post.Id, true, false, true) oldFiles, err := a.Srv().Store().FileInfo().GetForPost(post.Id, true, false, true)
if err != nil { 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 { for _, oldFile := range oldFiles {
if oldFile.Name != path.Base(name) || oldFile.Size != fileSize { 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) oldFileReader, appErr := a.FileReader(oldFile.Path)
if appErr != nil { 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() defer oldFileReader.Close()
@@ -2564,7 +2564,7 @@ func (a *App) importEmoji(rctx request.CTX, data *imports.EmojiImportData, dryRu
file, err = os.Open(*data.Image) file, err = os.Open(*data.Image)
} }
if err != nil { 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() defer file.Close()

Просмотреть файл

@@ -343,7 +343,7 @@ func (a *App) DoActionRequest(c request.CTX, rawURL string, body []byte) (*http.
resp, httpErr := httpClient.Do(req) resp, httpErr := httpClient.Do(req)
if httpErr != nil { 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 { if resp.StatusCode != http.StatusOK {
@@ -384,7 +384,7 @@ func (ch *Channels) doPluginRequest(c request.CTX, method, rawURL string, values
rawURL = strings.TrimPrefix(rawURL, "/") rawURL = strings.TrimPrefix(rawURL, "/")
inURL, err := url.Parse(rawURL) inURL, err := url.Parse(rawURL)
if err != nil { 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, "/") result := strings.Split(inURL.Path, "/")
if len(result) < 2 { if len(result) < 2 {
@@ -399,7 +399,7 @@ func (ch *Channels) doPluginRequest(c request.CTX, method, rawURL string, values
base, err := url.Parse(path) base, err := url.Parse(path)
if err != nil { 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 // 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{} w := &LocalResponseWriter{}
r, err := http.NewRequest(method, base.String(), bytes.NewReader(body)) r, err := http.NewRequest(method, base.String(), bytes.NewReader(body))
if err != nil { 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("Mattermost-User-Id", c.Session().UserId)
r.Header.Set(model.HeaderAuth, "Bearer "+c.Session().Token) r.Header.Set(model.HeaderAuth, "Bearer "+c.Session().Token)

Просмотреть файл

@@ -10,7 +10,6 @@ import (
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"net/url" "net/url"
"strings"
"testing" "testing"
"time" "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) _, err = th.App.DoPostActionWithCookie(th.Context, post.Id, attachments[0].Actions[0].Id, th.BasicUser.Id, "", nil)
require.NotNil(t, err) 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) { 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) _, err = th.App.DoPostActionWithCookie(th.Context, post.Id, attachments[0].Actions[0].Id, th.BasicUser.Id, "", nil)
require.NotNil(t, err) 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) _, err = th.App.DoPostActionWithCookie(th.Context, post.Id, attachments[0].Actions[0].Id, th.BasicUser.Id, "", nil)
require.NotNil(t, err) require.NotNil(t, err)
require.True(t, strings.Contains(err.Error(), "address forbidden")) assert.ErrorContains(t, err, "address forbidden")
interactivePostPlugin := model.Post{ interactivePostPlugin := model.Post{
Message: "Interactive 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) _, err = th.App.DoPostActionWithCookie(th.Context, postSiteURL.Id, attachmentsSiteURL[0].Actions[0].Id, th.BasicUser.Id, "", nil)
require.NotNil(t, err) 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) { th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.ServiceSettings.SiteURL = ts.URL + "/subpath" *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) oauthApp, err := a.GetOAuthApp(authRequest.ClientId)
if err != nil { 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) 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} 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 { 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 return session, nil
@@ -276,7 +276,7 @@ func (a *App) GetOAuthAccessTokenForCodeFlow(c request.CTX, clientId, grantType,
oauthApp, nErr := a.Srv().Store().OAuth().GetApp(clientId) oauthApp, nErr := a.Srv().Store().OAuth().GetApp(clientId)
if nErr != nil { 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 { if oauthApp.ClientSecret != secret {
@@ -290,7 +290,7 @@ func (a *App) GetOAuthAccessTokenForCodeFlow(c request.CTX, clientId, grantType,
var authData *model.AuthData var authData *model.AuthData
authData, nErr = a.Srv().Store().OAuth().GetAuthData(code) authData, nErr = a.Srv().Store().OAuth().GetAuthData(code)
if nErr != nil { 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() { 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) user, nErr = a.Srv().Store().User().Get(context.Background(), authData.UserId)
if nErr != nil { 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 { 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) accessData, nErr = a.Srv().Store().OAuth().GetPreviousAccessData(user.Id, clientId)
if nErr != nil { 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 { 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} 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 { 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{ accessRsp = &model.AccessResponse{
@@ -364,12 +364,12 @@ func (a *App) GetOAuthAccessTokenForCodeFlow(c request.CTX, clientId, grantType,
// When grantType is refresh_token // When grantType is refresh_token
accessData, nErr = a.Srv().Store().OAuth().GetAccessDataByRefreshToken(refreshToken) accessData, nErr = a.Srv().Store().OAuth().GetAccessDataByRefreshToken(refreshToken)
if nErr != nil { 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) user, nErr := a.Srv().Store().User().Get(context.Background(), accessData.UserId)
if nErr != nil { 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) 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) session, err := a.Srv().Store().Session().Save(c, session)
if err != nil { 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) 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 accessData.ExpiresAt = session.ExpiresAt
if _, err := a.Srv().Store().OAuth().UpdateAccessData(accessData); err != nil { 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{ accessRsp := &model.AccessResponse{
AccessToken: session.Token, 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) { func (api *PluginAPI) UpsertGroupMember(groupID string, userID string) (*model.GroupMember, *model.AppError) {
if err := api.checkLDAPLicense(); err != nil { 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) return api.app.UpsertGroupMember(groupID, userID)
} }
func (api *PluginAPI) UpsertGroupMembers(groupID string, userIDs []string) ([]*model.GroupMember, *model.AppError) { func (api *PluginAPI) UpsertGroupMembers(groupID string, userIDs []string) ([]*model.GroupMember, *model.AppError) {
if err := api.checkLDAPLicense(); err != nil { 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) return api.app.UpsertGroupMembers(groupID, userIDs)
} }
func (api *PluginAPI) GetGroupByRemoteID(remoteID string, groupSource model.GroupSource) (*model.Group, *model.AppError) { func (api *PluginAPI) GetGroupByRemoteID(remoteID string, groupSource model.GroupSource) (*model.Group, *model.AppError) {
if err := api.checkLDAPLicense(); err != nil { 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) return api.app.GetGroupByRemoteID(remoteID, groupSource)
} }
func (api *PluginAPI) CreateGroup(group *model.Group) (*model.Group, *model.AppError) { func (api *PluginAPI) CreateGroup(group *model.Group) (*model.Group, *model.AppError) {
if err := api.checkLDAPLicense(); err != nil { 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) return api.app.CreateGroup(group)
} }
func (api *PluginAPI) UpdateGroup(group *model.Group) (*model.Group, *model.AppError) { func (api *PluginAPI) UpdateGroup(group *model.Group) (*model.Group, *model.AppError) {
if err := api.checkLDAPLicense(); err != nil { 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) return api.app.UpdateGroup(group)
} }
func (api *PluginAPI) DeleteGroup(groupID string) (*model.Group, *model.AppError) { func (api *PluginAPI) DeleteGroup(groupID string) (*model.Group, *model.AppError) {
if err := api.checkLDAPLicense(); err != nil { 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) return api.app.DeleteGroup(groupID)
} }
func (api *PluginAPI) RestoreGroup(groupID string) (*model.Group, *model.AppError) { func (api *PluginAPI) RestoreGroup(groupID string) (*model.Group, *model.AppError) {
if err := api.checkLDAPLicense(); err != nil { 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) return api.app.RestoreGroup(groupID)
} }
func (api *PluginAPI) DeleteGroupMember(groupID string, userID string) (*model.GroupMember, *model.AppError) { func (api *PluginAPI) DeleteGroupMember(groupID string, userID string) (*model.GroupMember, *model.AppError) {
if err := api.checkLDAPLicense(); err != nil { 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) return api.app.DeleteGroupMember(groupID, userID)
} }
func (api *PluginAPI) GetGroupSyncable(groupID string, syncableID string, syncableType model.GroupSyncableType) (*model.GroupSyncable, *model.AppError) { func (api *PluginAPI) GetGroupSyncable(groupID string, syncableID string, syncableType model.GroupSyncableType) (*model.GroupSyncable, *model.AppError) {
if err := api.checkLDAPLicense(); err != nil { 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) return api.app.GetGroupSyncable(groupID, syncableID, syncableType)
} }
func (api *PluginAPI) GetGroupSyncables(groupID string, syncableType model.GroupSyncableType) ([]*model.GroupSyncable, *model.AppError) { func (api *PluginAPI) GetGroupSyncables(groupID string, syncableType model.GroupSyncableType) ([]*model.GroupSyncable, *model.AppError) {
if err := api.checkLDAPLicense(); err != nil { 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) return api.app.GetGroupSyncables(groupID, syncableType)
} }
func (api *PluginAPI) UpsertGroupSyncable(groupSyncable *model.GroupSyncable) (*model.GroupSyncable, *model.AppError) { func (api *PluginAPI) UpsertGroupSyncable(groupSyncable *model.GroupSyncable) (*model.GroupSyncable, *model.AppError) {
if err := api.checkLDAPLicense(); err != nil { 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) return api.app.UpsertGroupSyncable(groupSyncable)
} }
func (api *PluginAPI) UpdateGroupSyncable(groupSyncable *model.GroupSyncable) (*model.GroupSyncable, *model.AppError) { func (api *PluginAPI) UpdateGroupSyncable(groupSyncable *model.GroupSyncable) (*model.GroupSyncable, *model.AppError) {
if err := api.checkLDAPLicense(); err != nil { 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) return api.app.UpdateGroupSyncable(groupSyncable)
} }
func (api *PluginAPI) DeleteGroupSyncable(groupID string, syncableID string, syncableType model.GroupSyncableType) (*model.GroupSyncable, *model.AppError) { func (api *PluginAPI) DeleteGroupSyncable(groupID string, syncableID string, syncableType model.GroupSyncableType) (*model.GroupSyncable, *model.AppError) {
if err := api.checkLDAPLicense(); err != nil { 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) 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) fileBuffer, err := io.ReadAll(file)
if err != nil { 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) 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) { func (api *PluginAPI) GetGroups(page, perPage int, opts model.GroupSearchOpts, viewRestrictions *model.ViewUsersRestrictions) ([]*model.Group, *model.AppError) {
if err := api.checkLDAPLicense(); err != nil { 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) 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 // Checking if plugin is working or not
if err := pluginsEnvironment.PerformHealthCheck(matched.PluginId); err != nil { 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) pluginHooks, err := pluginsEnvironment.HooksForPlugin(matched.PluginId)
if err != nil { 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) { 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 { if prepackagedPlugin != nil {
fileReader, err := os.Open(prepackagedPlugin.Path) fileReader, err := os.Open(prepackagedPlugin.Path)
if err != nil { 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() defer fileReader.Close()
@@ -459,12 +459,12 @@ func (ch *Channels) installExtractedPlugin(manifest *model.Manifest, fromPluginD
version, err = semver.Parse(manifest.Version) version, err = semver.Parse(manifest.Version)
if err != nil { 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) existingVersion, err = semver.Parse(existingManifest.Version)
if err != nil { 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) { 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. // 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)) logger.Info("Removing existing installation of plugin before local install", mlog.String("existing_version", existingManifest.Version))
if err := ch.removePluginLocally(existingManifest.Id); err != nil { 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 { if pchan != nil {
result := <-pchan result := <-pchan
if result.NErr != nil { 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 parentPostList = result.Data
if len(parentPostList.Posts) == 0 || !parentPostList.IsChannelId(post.ChannelId) { 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 { 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) postListResponse, appErr := a.GetPostThread(postID, model.GetPostsOptions{}, user.Id)
if appErr != nil { 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() wpl := postListResponse.BuildWranglerPostList()

Просмотреть файл

@@ -32,7 +32,7 @@ func (a *App) GetSamlMetadata(c request.CTX) (string, *model.AppError) {
result, err := a.Saml().GetMetadata(c) result, err := a.Saml().GetMetadata(c)
if err != nil { 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 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) savedScheduledPost, err := a.Srv().Store().ScheduledPost().CreateScheduledPost(scheduledPost)
if err != nil { 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) 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) { func (a *App) GetUserTeamScheduledPosts(rctx request.CTX, userId, teamId string) ([]*model.ScheduledPost, *model.AppError) {
scheduledPosts, err := a.Srv().Store().ScheduledPost().GetScheduledPostsForUser(userId, teamId) scheduledPosts, err := a.Srv().Store().ScheduledPost().GetScheduledPostsForUser(userId, teamId)
if err != nil { 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 { 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 // validate the scheduled post belongs to the said user
existingScheduledPost, err := a.Srv().Store().ScheduledPost().Get(scheduledPost.Id) existingScheduledPost, err := a.Srv().Store().ScheduledPost().Get(scheduledPost.Id)
if err != nil { 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 { if existingScheduledPost == nil {
@@ -82,7 +82,7 @@ func (a *App) UpdateScheduledPost(rctx request.CTX, userId string, scheduledPost
scheduledPost.RestoreNonUpdatableFields(existingScheduledPost) scheduledPost.RestoreNonUpdatableFields(existingScheduledPost)
if err := a.Srv().Store().ScheduledPost().UpdatedScheduledPost(scheduledPost); err != nil { 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) 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) { func (a *App) DeleteScheduledPost(rctx request.CTX, userId, scheduledPostId, connectionId string) (*model.ScheduledPost, *model.AppError) {
scheduledPost, err := a.Srv().Store().ScheduledPost().Get(scheduledPostId) scheduledPost, err := a.Srv().Store().ScheduledPost().Get(scheduledPostId)
if err != nil { 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 { 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 { 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) 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) 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) 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 != "" { if tokenID != "" {
token, err := a.Srv().Store().Token().GetByToken(tokenID) token, err := a.Srv().Store().Token().GetByToken(tokenID)
if err != nil { 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 { 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 { func (a *App) SetProfileImageFromMultiPartFile(c request.CTX, userID string, file multipart.File) *model.AppError {
if limitErr := checkImageLimits(file, *a.Config().FileSettings.MaxImageResolution); limitErr != 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)
} }
return a.SetProfileImageFromFile(c, userID, file) 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) result, eErr := a.Srv().EmailService.SendPasswordResetEmail(user.Email, token, user.Locale, siteURL)
if eErr != nil { 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 return result, nil

Просмотреть файл

@@ -372,7 +372,7 @@ func (a *App) CreateWebhookPost(c request.CTX, userID string, channel *model.Cha
for _, split := range splits { for _, split := range splits {
if _, err = a.CreatePost(c, split, channel, model.CreatePostFlags{}); err != nil { 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) defer closeBody(r)
var p Group var p Group
if jsonErr := json.NewDecoder(r.Body).Decode(&p); jsonErr != nil { if err := json.NewDecoder(r.Body).Decode(&p); err != nil {
return nil, nil, NewAppError("DeleteGroup", "api.unmarshal_error", nil, jsonErr.Error(), http.StatusInternalServerError) return nil, nil, NewAppError("DeleteGroup", "api.unmarshal_error", nil, "", http.StatusInternalServerError).Wrap(err)
} }
return &p, BuildResponse(r), nil return &p, BuildResponse(r), nil
} }
@@ -9241,8 +9241,8 @@ func (c *Client4) AcknowledgePost(ctx context.Context, postId, userId string) (*
} }
defer closeBody(r) defer closeBody(r)
var ack *PostAcknowledgement var ack *PostAcknowledgement
if jsonErr := json.NewDecoder(r.Body).Decode(&ack); jsonErr != nil { if err := json.NewDecoder(r.Body).Decode(&ack); err != nil {
return nil, nil, NewAppError("AcknowledgePost", "api.unmarshal_error", nil, jsonErr.Error(), http.StatusInternalServerError) return nil, nil, NewAppError("AcknowledgePost", "api.unmarshal_error", nil, "", http.StatusInternalServerError).Wrap(err)
} }
return ack, BuildResponse(r), nil return ack, BuildResponse(r), nil
} }

Просмотреть файл

@@ -4370,7 +4370,7 @@ func (s *ServiceSettings) isValid() *AppError {
parent := filepath.Dir(*s.LocalModeSocketLocation) parent := filepath.Dir(*s.LocalModeSocketLocation)
_, err := os.Stat(parent) _, err := os.Stat(parent)
if err != nil { 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)
} }
} }