Преглед на файлове

use notification state id instead of notifier id

bergquist преди 7 години
родител
ревизия
7b781e4c3c
променени са 2 файла, в които са добавени 4 реда и са изтрити 4 реда
  1. 3 3
      pkg/services/alerting/notifier.go
  2. 1 1
      pkg/services/sqlstore/alert_notification.go

+ 3 - 3
pkg/services/alerting/notifier.go

@@ -74,7 +74,7 @@ func (n *notificationService) sendAndMarkAsComplete(evalContext *EvalContext, no
 	}
 
 	cmd := &m.SetAlertNotificationStateToCompleteCommand{
-		Id:      notifier.GetNotifierId(),
+		Id:      notifierState.state.Id,
 		Version: notifierState.state.Version,
 	}
 
@@ -84,7 +84,7 @@ func (n *notificationService) sendAndMarkAsComplete(evalContext *EvalContext, no
 func (n *notificationService) sendNotification(evalContext *EvalContext, notifierState *notifierState) error {
 	if !evalContext.IsTestRun {
 		setPendingCmd := &m.SetAlertNotificationStateToPendingCommand{
-			Id:                           notifierState.state.NotifierId,
+			Id:                           notifierState.state.Id,
 			Version:                      notifierState.state.Version,
 			AlertRuleStateUpdatedVersion: evalContext.Rule.StateChanges,
 		}
@@ -110,7 +110,7 @@ func (n *notificationService) sendNotifications(evalContext *EvalContext, notifi
 	for _, notifierState := range notifierStates {
 		err := n.sendNotification(evalContext, notifierState)
 		if err != nil {
-			n.log.Error("failed to send notification", "id", notifierState.notifier.GetNotifierId())
+			n.log.Error("failed to send notification", "id", notifierState.notifier.GetNotifierId(), "error", err)
 		}
 	}
 

+ 1 - 1
pkg/services/sqlstore/alert_notification.go

@@ -238,7 +238,7 @@ func UpdateAlertNotification(cmd *m.UpdateAlertNotificationCommand) error {
 }
 
 func SetAlertNotificationStateToCompleteCommand(ctx context.Context, cmd *m.SetAlertNotificationStateToCompleteCommand) error {
-	return withDbSession(ctx, func(sess *DBSession) error {
+	return inTransactionCtx(ctx, func(sess *DBSession) error {
 		version := cmd.Version
 		var current m.AlertNotificationState
 		sess.ID(cmd.Id).Get(&current)