Update notifies after successful sending
This commit is contained in:
parent
95b57b3622
commit
40b0505afa
15
notify.go
15
notify.go
|
@ -59,6 +59,8 @@ func (n *dedupingNotifier) Notify(ctx context.Context, alerts ...*types.Alert) e
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
|
var newNotifies []*types.Notify
|
||||||
|
|
||||||
var filtered []*types.Alert
|
var filtered []*types.Alert
|
||||||
for i, a := range alerts {
|
for i, a := range alerts {
|
||||||
last := notifies[i]
|
last := notifies[i]
|
||||||
|
@ -78,6 +80,7 @@ func (n *dedupingNotifier) Notify(ctx context.Context, alerts ...*types.Alert) e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newNotifies = append(newNotifies, last)
|
||||||
filtered = append(filtered, a)
|
filtered = append(filtered, a)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +88,17 @@ func (n *dedupingNotifier) Notify(ctx context.Context, alerts ...*types.Alert) e
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
// Properly set new notifies which are currently copies of the
|
||||||
|
// old ones.
|
||||||
|
for i, notify := range newNotifies {
|
||||||
|
alert := filtered[i]
|
||||||
|
|
||||||
|
notify.Delivered = true
|
||||||
|
notify.Resolved = alert.Resolved()
|
||||||
|
notify.Timestamp = now
|
||||||
|
}
|
||||||
|
|
||||||
|
return n.notifier.Set(name, newNotifies...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// routedNotifier dispatches the alerts to one of a set of
|
// routedNotifier dispatches the alerts to one of a set of
|
||||||
|
|
Loading…
Reference in New Issue