diff --git a/server/channels/api4/brand.go b/server/channels/api4/brand.go index 7cbe4141ee..44b1bfc89e 100644 --- a/server/channels/api4/brand.go +++ b/server/channels/api4/brand.go @@ -20,7 +20,7 @@ func (api *API) InitBrand() { func getBrandImage(c *Context, w http.ResponseWriter, r *http.Request) { // No permission check required - img, err := c.App.GetBrandImage() + img, err := c.App.GetBrandImage(c.AppContext) if err != nil { w.WriteHeader(http.StatusNotFound) w.Write(nil) @@ -65,7 +65,7 @@ func uploadBrandImage(c *Context, w http.ResponseWriter, r *http.Request) { return } - if err := c.App.SaveBrandImage(imageArray[0]); err != nil { + if err := c.App.SaveBrandImage(c.AppContext, imageArray[0]); err != nil { c.Err = err return } @@ -86,7 +86,7 @@ func deleteBrandImage(c *Context, w http.ResponseWriter, r *http.Request) { return } - if err := c.App.DeleteBrandImage(); err != nil { + if err := c.App.DeleteBrandImage(c.AppContext); err != nil { c.Err = err return } diff --git a/server/channels/app/app_iface.go b/server/channels/app/app_iface.go index 178635ae3a..3086ddf9c2 100644 --- a/server/channels/app/app_iface.go +++ b/server/channels/app/app_iface.go @@ -520,7 +520,7 @@ type AppIface interface { DeleteAcknowledgementForPost(c request.CTX, postID, userID string) *model.AppError DeleteAllExpiredPluginKeys() *model.AppError DeleteAllKeysForPlugin(pluginID string) *model.AppError - DeleteBrandImage() *model.AppError + DeleteBrandImage(rctx request.CTX) *model.AppError DeleteChannel(c request.CTX, channel *model.Channel, userID string) *model.AppError DeleteCommand(commandID string) *model.AppError DeleteDraft(rctx request.CTX, userID, channelID, rootID, connectionID string) (*model.Draft, *model.AppError) @@ -600,7 +600,7 @@ type AppIface interface { GetAuditsPage(rctx request.CTX, userID string, page int, perPage int) (model.Audits, *model.AppError) GetAuthorizationCode(c request.CTX, w http.ResponseWriter, r *http.Request, service string, props map[string]string, loginHint string) (string, *model.AppError) GetAuthorizedAppsForUser(userID string, page, perPage int) ([]*model.OAuthApp, *model.AppError) - GetBrandImage() ([]byte, *model.AppError) + GetBrandImage(rctx request.CTX) ([]byte, *model.AppError) GetBulkReactionsForPosts(postIDs []string) (map[string][]*model.Reaction, *model.AppError) GetChannel(c request.CTX, channelID string) (*model.Channel, *model.AppError) GetChannelByName(c request.CTX, channelName, teamID string, includeDeleted bool) (*model.Channel, *model.AppError) @@ -1007,7 +1007,7 @@ type AppIface interface { SaveAcknowledgementForPost(c request.CTX, postID, userID string) (*model.PostAcknowledgement, *model.AppError) SaveAdminNotification(userId string, notifyData *model.NotifyAdminToUpgradeRequest) *model.AppError SaveAdminNotifyData(data *model.NotifyAdminData) (*model.NotifyAdminData, *model.AppError) - SaveBrandImage(imageData *multipart.FileHeader) *model.AppError + SaveBrandImage(rctx request.CTX, imageData *multipart.FileHeader) *model.AppError SaveComplianceReport(rctx request.CTX, job *model.Compliance) (*model.Compliance, *model.AppError) SaveReactionForPost(c request.CTX, reaction *model.Reaction) (*model.Reaction, *model.AppError) SaveSharedChannel(c request.CTX, sc *model.SharedChannel) (*model.SharedChannel, error) diff --git a/server/channels/app/brand.go b/server/channels/app/brand.go index 3ffce918a5..68dae47f3f 100644 --- a/server/channels/app/brand.go +++ b/server/channels/app/brand.go @@ -10,6 +10,7 @@ import ( "time" "github.com/mattermost/mattermost/server/public/model" + "github.com/mattermost/mattermost/server/public/shared/request" ) const ( @@ -17,7 +18,7 @@ const ( BrandFileName = "image.png" ) -func (a *App) SaveBrandImage(imageData *multipart.FileHeader) *model.AppError { +func (a *App) SaveBrandImage(rctx request.CTX, imageData *multipart.FileHeader) *model.AppError { if *a.Config().FileSettings.DriverName == "" { return model.NewAppError("SaveBrandImage", "api.admin.upload_brand_image.storage.app_error", nil, "", http.StatusNotImplemented) } @@ -53,7 +54,7 @@ func (a *App) SaveBrandImage(imageData *multipart.FileHeader) *model.AppError { return nil } -func (a *App) GetBrandImage() ([]byte, *model.AppError) { +func (a *App) GetBrandImage(rctx request.CTX) ([]byte, *model.AppError) { if *a.Config().FileSettings.DriverName == "" { return nil, model.NewAppError("GetBrandImage", "api.admin.get_brand_image.storage.app_error", nil, "", http.StatusNotImplemented) } @@ -66,7 +67,7 @@ func (a *App) GetBrandImage() ([]byte, *model.AppError) { return img, nil } -func (a *App) DeleteBrandImage() *model.AppError { +func (a *App) DeleteBrandImage(rctx request.CTX) *model.AppError { filePath := BrandFilePath + BrandFileName fileExists, err := a.FileExists(filePath) diff --git a/server/channels/app/opentracing/opentracing_layer.go b/server/channels/app/opentracing/opentracing_layer.go index 15bd6138d6..2162b47ae7 100644 --- a/server/channels/app/opentracing/opentracing_layer.go +++ b/server/channels/app/opentracing/opentracing_layer.go @@ -2961,7 +2961,7 @@ func (a *OpenTracingAppLayer) DeleteAllKeysForPlugin(pluginID string) *model.App return resultVar0 } -func (a *OpenTracingAppLayer) DeleteBrandImage() *model.AppError { +func (a *OpenTracingAppLayer) DeleteBrandImage(rctx request.CTX) *model.AppError { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.DeleteBrandImage") @@ -2973,7 +2973,7 @@ func (a *OpenTracingAppLayer) DeleteBrandImage() *model.AppError { }() defer span.Finish() - resultVar0 := a.app.DeleteBrandImage() + resultVar0 := a.app.DeleteBrandImage(rctx) if resultVar0 != nil { span.LogFields(spanlog.Error(resultVar0)) @@ -5123,7 +5123,7 @@ func (a *OpenTracingAppLayer) GetBots(options *model.BotGetOptions) (model.BotLi return resultVar0, resultVar1 } -func (a *OpenTracingAppLayer) GetBrandImage() ([]byte, *model.AppError) { +func (a *OpenTracingAppLayer) GetBrandImage(rctx request.CTX) ([]byte, *model.AppError) { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetBrandImage") @@ -5135,7 +5135,7 @@ func (a *OpenTracingAppLayer) GetBrandImage() ([]byte, *model.AppError) { }() defer span.Finish() - resultVar0, resultVar1 := a.app.GetBrandImage() + resultVar0, resultVar1 := a.app.GetBrandImage(rctx) if resultVar1 != nil { span.LogFields(spanlog.Error(resultVar1)) @@ -14716,7 +14716,7 @@ func (a *OpenTracingAppLayer) SaveAdminNotifyData(data *model.NotifyAdminData) ( return resultVar0, resultVar1 } -func (a *OpenTracingAppLayer) SaveBrandImage(imageData *multipart.FileHeader) *model.AppError { +func (a *OpenTracingAppLayer) SaveBrandImage(rctx request.CTX, imageData *multipart.FileHeader) *model.AppError { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SaveBrandImage") @@ -14728,7 +14728,7 @@ func (a *OpenTracingAppLayer) SaveBrandImage(imageData *multipart.FileHeader) *m }() defer span.Finish() - resultVar0 := a.app.SaveBrandImage(imageData) + resultVar0 := a.app.SaveBrandImage(rctx, imageData) if resultVar0 != nil { span.LogFields(spanlog.Error(resultVar0))