Rename DispatchCtx to Dispatch (#43563)
This commit is contained in:
+21
-21
@@ -24,7 +24,7 @@ func ValidateOrgAlert(c *models.ReqContext) {
|
||||
id := c.ParamsInt64(":alertId")
|
||||
query := models.GetAlertByIdQuery{Id: id}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
c.JsonApiErr(404, "Alert not found", nil)
|
||||
return
|
||||
}
|
||||
@@ -47,7 +47,7 @@ func GetAlertStatesForDashboard(c *models.ReqContext) response.Response {
|
||||
DashboardId: c.QueryInt64("dashboardId"),
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(500, "Failed to fetch alert states", err)
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ func GetAlerts(c *models.ReqContext) response.Response {
|
||||
Permission: models.PERMISSION_VIEW,
|
||||
}
|
||||
|
||||
err := bus.DispatchCtx(c.Req.Context(), &searchQuery)
|
||||
err := bus.Dispatch(c.Req.Context(), &searchQuery)
|
||||
if err != nil {
|
||||
return response.Error(500, "List alerts failed", err)
|
||||
}
|
||||
@@ -121,7 +121,7 @@ func GetAlerts(c *models.ReqContext) response.Response {
|
||||
query.State = states
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(500, "List alerts failed", err)
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ func GetAlert(c *models.ReqContext) response.Response {
|
||||
id := c.ParamsInt64(":alertId")
|
||||
query := models.GetAlertByIdQuery{Id: id}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(500, "List alerts failed", err)
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ func GetAlertNotifications(c *models.ReqContext) response.Response {
|
||||
func getAlertNotificationsInternal(c *models.ReqContext) ([]*models.AlertNotification, error) {
|
||||
query := &models.GetAllAlertNotificationsQuery{OrgId: c.OrgId}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), query); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ func GetAlertNotificationByID(c *models.ReqContext) response.Response {
|
||||
return response.Error(404, "Alert notification not found", nil)
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), query); err != nil {
|
||||
return response.Error(500, "Failed to get alert notifications", err)
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ func GetAlertNotificationByUID(c *models.ReqContext) response.Response {
|
||||
return response.Error(404, "Alert notification not found", nil)
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), query); err != nil {
|
||||
return response.Error(500, "Failed to get alert notifications", err)
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ func CreateAlertNotification(c *models.ReqContext) response.Response {
|
||||
}
|
||||
cmd.OrgId = c.OrgId
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
if errors.Is(err, models.ErrAlertNotificationWithSameNameExists) || errors.Is(err, models.ErrAlertNotificationWithSameUIDExists) {
|
||||
return response.Error(409, "Failed to create alert notification", err)
|
||||
}
|
||||
@@ -314,7 +314,7 @@ func (hs *HTTPServer) UpdateAlertNotification(c *models.ReqContext) response.Res
|
||||
return response.Error(500, "Failed to update alert notification", err)
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
if errors.Is(err, models.ErrAlertNotificationNotFound) {
|
||||
return response.Error(404, err.Error(), err)
|
||||
}
|
||||
@@ -330,7 +330,7 @@ func (hs *HTTPServer) UpdateAlertNotification(c *models.ReqContext) response.Res
|
||||
Id: cmd.Id,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(500, "Failed to get alert notification", err)
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@ func (hs *HTTPServer) UpdateAlertNotificationByUID(c *models.ReqContext) respons
|
||||
return response.Error(500, "Failed to update alert notification", err)
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
if errors.Is(err, models.ErrAlertNotificationNotFound) {
|
||||
return response.Error(404, err.Error(), nil)
|
||||
}
|
||||
@@ -362,7 +362,7 @@ func (hs *HTTPServer) UpdateAlertNotificationByUID(c *models.ReqContext) respons
|
||||
Uid: cmd.Uid,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(500, "Failed to get alert notification", err)
|
||||
}
|
||||
|
||||
@@ -379,7 +379,7 @@ func (hs *HTTPServer) fillWithSecureSettingsData(ctx context.Context, cmd *model
|
||||
Id: cmd.Id,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(ctx, query); err != nil {
|
||||
if err := bus.Dispatch(ctx, query); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -407,7 +407,7 @@ func (hs *HTTPServer) fillWithSecureSettingsDataByUID(ctx context.Context, cmd *
|
||||
Uid: cmd.Uid,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(ctx, query); err != nil {
|
||||
if err := bus.Dispatch(ctx, query); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -431,7 +431,7 @@ func DeleteAlertNotification(c *models.ReqContext) response.Response {
|
||||
Id: c.ParamsInt64(":notificationId"),
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
if errors.Is(err, models.ErrAlertNotificationNotFound) {
|
||||
return response.Error(404, err.Error(), nil)
|
||||
}
|
||||
@@ -447,7 +447,7 @@ func DeleteAlertNotificationByUID(c *models.ReqContext) response.Response {
|
||||
Uid: web.Params(c.Req)[":uid"],
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
if errors.Is(err, models.ErrAlertNotificationNotFound) {
|
||||
return response.Error(404, err.Error(), nil)
|
||||
}
|
||||
@@ -475,7 +475,7 @@ func NotificationTest(c *models.ReqContext) response.Response {
|
||||
SecureSettings: dto.SecureSettings,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), cmd); err != nil {
|
||||
if errors.Is(err, models.ErrSmtpNotEnabled) {
|
||||
return response.Error(412, err.Error(), err)
|
||||
}
|
||||
@@ -501,7 +501,7 @@ func PauseAlert(c *models.ReqContext) response.Response {
|
||||
result["alertId"] = alertID
|
||||
|
||||
query := models.GetAlertByIdQuery{Id: alertID}
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(500, "Get Alert failed", err)
|
||||
}
|
||||
|
||||
@@ -531,7 +531,7 @@ func PauseAlert(c *models.ReqContext) response.Response {
|
||||
Paused: dto.Paused,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
return response.Error(500, "", err)
|
||||
}
|
||||
|
||||
@@ -557,7 +557,7 @@ func PauseAllAlerts(c *models.ReqContext) response.Response {
|
||||
Paused: dto.Paused,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &updateCmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &updateCmd); err != nil {
|
||||
return response.Error(500, "Failed to pause alerts", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user