diff --git a/main.go b/main.go index 35e2102..d158722 100644 --- a/main.go +++ b/main.go @@ -51,6 +51,8 @@ type notification struct { priority string tags string silenceBody string + fingerprint fingerprint + status string } func (rcv *receiver) singleAlertNotifications(p *payload) []*notification { @@ -60,9 +62,10 @@ func (rcv *receiver) singleAlertNotifications(p *payload) []*notification { rcv.logger.Debugf("Alert %s skipped: Still in cache", alert.Fingerprint) continue } - rcv.cache.set(alert.Fingerprint, status(alert.Status)) n := new(notification) + n.fingerprint = alert.Fingerprint + n.status = alert.Status // create title n.title = fmt.Sprintf("[%s]", strings.ToUpper(alert.Status)) @@ -297,6 +300,8 @@ func (rcv *receiver) handleWebhooks(w http.ResponseWriter, r *http.Request) { err := rcv.publish(n) if err != nil { rcv.logger.Errorf("Failed to publish notification: %v", err) + } else { + rcv.cache.set(n.fingerprint, status(n.status)) } } } else {