Skip to content

Commit

Permalink
Add the request context and logger to all public methods in server/ch…
Browse files Browse the repository at this point in the history
…annels/app/auto_responder.go (mattermost#25295)

Co-authored-by: Mattermost Build <[email protected]>
  • Loading branch information
Davut97 and mattermost-build authored Nov 7, 2023
1 parent 9596c46 commit b19b62b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion server/channels/api4/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions server/channels/app/app_iface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions server/channels/app/auto_responder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand All @@ -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"

Expand All @@ -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
Expand All @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions server/channels/app/auto_responder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions server/channels/app/opentracing/opentracing_layer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b19b62b

Please sign in to comment.