diff --git a/server/channels/api4/user.go b/server/channels/api4/user.go index 2cf563e9379..5e7e15e4dce 100644 --- a/server/channels/api4/user.go +++ b/server/channels/api4/user.go @@ -1390,7 +1390,7 @@ func patchUser(c *Context, w http.ResponseWriter, r *http.Request) { return } - c.App.SetAutoResponderStatus(ruser, ouser.NotifyProps) + c.App.SetAutoResponderStatus(c.AppContext, ruser, ouser.NotifyProps) auditRec.Success() auditRec.AddEventResultState(ruser) diff --git a/server/channels/app/app_iface.go b/server/channels/app/app_iface.go index fa4e4b87b6a..b5fcb75d16e 100644 --- a/server/channels/app/app_iface.go +++ b/server/channels/app/app_iface.go @@ -545,7 +545,7 @@ type AppIface interface { DeleteSharedChannelRemote(id string) (bool, error) DeleteSidebarCategory(c request.CTX, userID, teamID, categoryId string) *model.AppError DeleteToken(token *model.Token) *model.AppError - DisableAutoResponder(c request.CTX, userID string, asAdmin bool) *model.AppError + DisableAutoResponder(rctx request.CTX, userID string, asAdmin bool) *model.AppError DisableUserAccessToken(c request.CTX, token *model.UserAccessToken) *model.AppError DoAppMigrations() DoCheckForAdminNotifications(trial bool) *model.AppError @@ -1035,8 +1035,8 @@ type AppIface interface { SearchUsersNotInTeam(notInTeamId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) SearchUsersWithoutTeam(term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) SendAckToPushProxy(ack *model.PushNotificationAck) error - SendAutoResponse(c request.CTX, channel *model.Channel, receiver *model.User, post *model.Post) (bool, *model.AppError) - SendAutoResponseIfNecessary(c request.CTX, channel *model.Channel, sender *model.User, post *model.Post) (bool, *model.AppError) + SendAutoResponse(rctx request.CTX, channel *model.Channel, receiver *model.User, post *model.Post) (bool, *model.AppError) + SendAutoResponseIfNecessary(rctx request.CTX, channel *model.Channel, sender *model.User, post *model.Post) (bool, *model.AppError) SendDelinquencyEmail(emailToSend model.DelinquencyEmail) *model.AppError SendEmailVerification(user *model.User, newEmail, redirect string) *model.AppError SendEphemeralPost(c request.CTX, userID string, post *model.Post) *model.Post @@ -1060,7 +1060,7 @@ type AppIface interface { SessionHasPermissionToUser(session model.Session, userID string) bool SessionHasPermissionToUserOrBot(session model.Session, userID string) bool SetActiveChannel(c request.CTX, userID string, channelID string) *model.AppError - SetAutoResponderStatus(user *model.User, oldNotifyProps model.StringMap) + SetAutoResponderStatus(rctx request.CTX, user *model.User, oldNotifyProps model.StringMap) SetChannels(ch *Channels) SetCustomStatus(c request.CTX, userID string, cs *model.CustomStatus) *model.AppError SetDefaultProfileImage(c request.CTX, user *model.User) *model.AppError diff --git a/server/channels/app/auto_responder.go b/server/channels/app/auto_responder.go index 55b80c19e84..6c58a58d0ea 100644 --- a/server/channels/app/auto_responder.go +++ b/server/channels/app/auto_responder.go @@ -21,7 +21,7 @@ func (a *App) checkIfRespondedToday(createdAt int64, channelId, userId string) ( ) } -func (a *App) SendAutoResponseIfNecessary(c request.CTX, channel *model.Channel, sender *model.User, post *model.Post) (bool, *model.AppError) { +func (a *App) SendAutoResponseIfNecessary(rctx request.CTX, channel *model.Channel, sender *model.User, post *model.Post) (bool, *model.AppError) { if channel.Type != model.ChannelTypeDirect { return false, nil } @@ -49,10 +49,10 @@ func (a *App) SendAutoResponseIfNecessary(c request.CTX, channel *model.Channel, return false, nil } - return a.SendAutoResponse(c, channel, receiver, post) + return a.SendAutoResponse(rctx, channel, receiver, post) } -func (a *App) SendAutoResponse(c request.CTX, channel *model.Channel, receiver *model.User, post *model.Post) (bool, *model.AppError) { +func (a *App) SendAutoResponse(rctx request.CTX, channel *model.Channel, receiver *model.User, post *model.Post) (bool, *model.AppError) { if receiver == nil || receiver.NotifyProps == nil { return false, nil } @@ -77,14 +77,14 @@ func (a *App) SendAutoResponse(c request.CTX, channel *model.Channel, receiver * UserId: receiver.Id, } - if _, err := a.CreatePost(c, autoResponderPost, channel, false, false); err != nil { + if _, err := a.CreatePost(rctx, autoResponderPost, channel, false, false); err != nil { return false, err } return true, nil } -func (a *App) SetAutoResponderStatus(user *model.User, oldNotifyProps model.StringMap) { +func (a *App) SetAutoResponderStatus(rctx request.CTX, user *model.User, oldNotifyProps model.StringMap) { active := user.NotifyProps[model.AutoResponderActiveNotifyProp] == "true" oldActive := oldNotifyProps[model.AutoResponderActiveNotifyProp] == "true" @@ -98,7 +98,7 @@ func (a *App) SetAutoResponderStatus(user *model.User, oldNotifyProps model.Stri } } -func (a *App) DisableAutoResponder(c request.CTX, userID string, asAdmin bool) *model.AppError { +func (a *App) DisableAutoResponder(rctx request.CTX, userID string, asAdmin bool) *model.AppError { user, err := a.GetUser(userID) if err != nil { return err @@ -111,7 +111,7 @@ func (a *App) DisableAutoResponder(c request.CTX, userID string, asAdmin bool) * patch.NotifyProps = user.NotifyProps patch.NotifyProps[model.AutoResponderActiveNotifyProp] = "false" - _, err := a.PatchUser(c, userID, patch, asAdmin) + _, err := a.PatchUser(rctx, userID, patch, asAdmin) if err != nil { return err } diff --git a/server/channels/app/auto_responder_test.go b/server/channels/app/auto_responder_test.go index e6f0a2a85cf..8e16552baa0 100644 --- a/server/channels/app/auto_responder_test.go +++ b/server/channels/app/auto_responder_test.go @@ -30,7 +30,7 @@ func TestSetAutoResponderStatus(t *testing.T) { userUpdated1, _ := th.App.PatchUser(th.Context, user.Id, patch, true) // autoResponder is enabled, status should be OOO - th.App.SetAutoResponderStatus(userUpdated1, user.NotifyProps) + th.App.SetAutoResponderStatus(th.Context, userUpdated1, user.NotifyProps) status, err := th.App.GetStatus(userUpdated1.Id) require.Nil(t, err) @@ -44,7 +44,7 @@ func TestSetAutoResponderStatus(t *testing.T) { userUpdated2, _ := th.App.PatchUser(th.Context, user.Id, patch2, true) // autoResponder is disabled, status should be ONLINE - th.App.SetAutoResponderStatus(userUpdated2, userUpdated1.NotifyProps) + th.App.SetAutoResponderStatus(th.Context, userUpdated2, userUpdated1.NotifyProps) status, err = th.App.GetStatus(userUpdated2.Id) require.Nil(t, err) diff --git a/server/channels/app/opentracing/opentracing_layer.go b/server/channels/app/opentracing/opentracing_layer.go index ab0c99c9576..c78cb5fd955 100644 --- a/server/channels/app/opentracing/opentracing_layer.go +++ b/server/channels/app/opentracing/opentracing_layer.go @@ -3614,7 +3614,7 @@ func (a *OpenTracingAppLayer) DemoteUserToGuest(c request.CTX, user *model.User) return resultVar0 } -func (a *OpenTracingAppLayer) DisableAutoResponder(c request.CTX, userID string, asAdmin bool) *model.AppError { +func (a *OpenTracingAppLayer) DisableAutoResponder(rctx request.CTX, userID string, asAdmin bool) *model.AppError { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.DisableAutoResponder") @@ -3626,7 +3626,7 @@ func (a *OpenTracingAppLayer) DisableAutoResponder(c request.CTX, userID string, }() defer span.Finish() - resultVar0 := a.app.DisableAutoResponder(c, userID, asAdmin) + resultVar0 := a.app.DisableAutoResponder(rctx, userID, asAdmin) if resultVar0 != nil { span.LogFields(spanlog.Error(resultVar0)) @@ -15393,7 +15393,7 @@ func (a *OpenTracingAppLayer) SendAckToPushProxy(ack *model.PushNotificationAck) return resultVar0 } -func (a *OpenTracingAppLayer) SendAutoResponse(c request.CTX, channel *model.Channel, receiver *model.User, post *model.Post) (bool, *model.AppError) { +func (a *OpenTracingAppLayer) SendAutoResponse(rctx request.CTX, channel *model.Channel, receiver *model.User, post *model.Post) (bool, *model.AppError) { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SendAutoResponse") @@ -15405,7 +15405,7 @@ func (a *OpenTracingAppLayer) SendAutoResponse(c request.CTX, channel *model.Cha }() defer span.Finish() - resultVar0, resultVar1 := a.app.SendAutoResponse(c, channel, receiver, post) + resultVar0, resultVar1 := a.app.SendAutoResponse(rctx, channel, receiver, post) if resultVar1 != nil { span.LogFields(spanlog.Error(resultVar1)) @@ -15415,7 +15415,7 @@ func (a *OpenTracingAppLayer) SendAutoResponse(c request.CTX, channel *model.Cha return resultVar0, resultVar1 } -func (a *OpenTracingAppLayer) SendAutoResponseIfNecessary(c request.CTX, channel *model.Channel, sender *model.User, post *model.Post) (bool, *model.AppError) { +func (a *OpenTracingAppLayer) SendAutoResponseIfNecessary(rctx request.CTX, channel *model.Channel, sender *model.User, post *model.Post) (bool, *model.AppError) { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SendAutoResponseIfNecessary") @@ -15427,7 +15427,7 @@ func (a *OpenTracingAppLayer) SendAutoResponseIfNecessary(c request.CTX, channel }() defer span.Finish() - resultVar0, resultVar1 := a.app.SendAutoResponseIfNecessary(c, channel, sender, post) + resultVar0, resultVar1 := a.app.SendAutoResponseIfNecessary(rctx, channel, sender, post) if resultVar1 != nil { span.LogFields(spanlog.Error(resultVar1)) @@ -15988,7 +15988,7 @@ func (a *OpenTracingAppLayer) SetActiveChannel(c request.CTX, userID string, cha return resultVar0 } -func (a *OpenTracingAppLayer) SetAutoResponderStatus(user *model.User, oldNotifyProps model.StringMap) { +func (a *OpenTracingAppLayer) SetAutoResponderStatus(rctx request.CTX, user *model.User, oldNotifyProps model.StringMap) { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SetAutoResponderStatus") @@ -16000,7 +16000,7 @@ func (a *OpenTracingAppLayer) SetAutoResponderStatus(user *model.User, oldNotify }() defer span.Finish() - a.app.SetAutoResponderStatus(user, oldNotifyProps) + a.app.SetAutoResponderStatus(rctx, user, oldNotifyProps) } func (a *OpenTracingAppLayer) SetChannels(ch *app.Channels) {