mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
wip: send and mark as complete
This commit is contained in:
@@ -100,8 +100,9 @@ type SetAlertNotificationStateToPendingCommand struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SetAlertNotificationStateToCompleteCommand struct {
|
type SetAlertNotificationStateToCompleteCommand struct {
|
||||||
Id int64
|
Id int64
|
||||||
SentAt int64
|
Version int64
|
||||||
|
SentAt int64
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetNotificationStateQuery struct {
|
type GetNotificationStateQuery struct {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package alerting
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/bus"
|
"github.com/grafana/grafana/pkg/bus"
|
||||||
"github.com/grafana/grafana/pkg/components/imguploader"
|
"github.com/grafana/grafana/pkg/components/imguploader"
|
||||||
@@ -53,17 +54,27 @@ func (n *notificationService) SendIfNeeded(context *EvalContext) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get alert notification (version = 1)
|
|
||||||
// phantomjs 15 sek
|
|
||||||
// loopa notifier - ge mig ett lås! where version = 1
|
|
||||||
// send notification
|
|
||||||
// Släpp lås
|
|
||||||
//
|
|
||||||
|
|
||||||
return n.sendNotifications(context, notifierStates)
|
return n.sendNotifications(context, notifierStates)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *notificationService) sendAndMarkAsComplete(evalContext *EvalContext, notifierState *NotifierState) error {
|
func (n *notificationService) sendAndMarkAsComplete(evalContext *EvalContext, notifierState *NotifierState) error {
|
||||||
|
err := notifierState.notifier.Notify(evalContext)
|
||||||
|
|
||||||
|
cmd := &m.SetAlertNotificationStateToCompleteCommand{
|
||||||
|
Id: notifierState.state.Id,
|
||||||
|
Version: notifierState.state.Version,
|
||||||
|
SentAt: time.Now().Unix(),
|
||||||
|
}
|
||||||
|
|
||||||
|
err = bus.DispatchCtx(evalContext.Ctx, cmd)
|
||||||
|
if err == m.ErrAlertNotificationStateVersionConflict {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user