Add context to notifications (#42578)

This commit is contained in:
idafurjes
2021-12-01 17:56:08 +01:00
committed by GitHub
parent 5183cc4dc4
commit 9880a843ed
5 changed files with 18 additions and 16 deletions
+3 -3
View File
@@ -86,7 +86,7 @@ func AddOrgInvite(c *models.ReqContext) response.Response {
},
}
if err := bus.Dispatch(&emailCmd); err != nil {
if err := bus.DispatchCtx(c.Req.Context(), &emailCmd); err != nil {
if errors.Is(err, models.ErrSmtpNotEnabled) {
return response.Error(412, err.Error(), err)
}
@@ -95,7 +95,7 @@ func AddOrgInvite(c *models.ReqContext) response.Response {
}
emailSentCmd := models.UpdateTempUserWithEmailSentCommand{Code: cmd.Result.Code}
if err := bus.Dispatch(&emailSentCmd); err != nil {
if err := bus.DispatchCtx(c.Req.Context(), &emailSentCmd); err != nil {
return response.Error(500, "Failed to update invite with email sent info", err)
}
@@ -126,7 +126,7 @@ func inviteExistingUserToOrg(c *models.ReqContext, user *models.User, inviteDto
},
}
if err := bus.Dispatch(&emailCmd); err != nil {
if err := bus.DispatchCtx(c.Req.Context(), &emailCmd); err != nil {
return response.Error(500, "Failed to send email invited_to_org", err)
}
}
+3 -3
View File
@@ -33,7 +33,7 @@ func SendResetPasswordEmail(c *models.ReqContext) response.Response {
}
emailCmd := models.SendResetPasswordEmailCommand{User: userQuery.Result}
if err := bus.Dispatch(&emailCmd); err != nil {
if err := bus.DispatchCtx(c.Req.Context(), &emailCmd); err != nil {
return response.Error(500, "Failed to send email", err)
}
@@ -47,7 +47,7 @@ func ResetPassword(c *models.ReqContext) response.Response {
}
query := models.ValidateResetPasswordCodeQuery{Code: form.Code}
if err := bus.Dispatch(&query); err != nil {
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
if errors.Is(err, models.ErrInvalidEmailCode) {
return response.Error(400, "Invalid or expired reset password code", nil)
}
@@ -66,7 +66,7 @@ func ResetPassword(c *models.ReqContext) response.Response {
return response.Error(500, "Failed to encode password", err)
}
if err := bus.Dispatch(&cmd); err != nil {
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
return response.Error(500, "Failed to change user password", err)
}