Added problem state in notification

This commit is contained in:
Magnus Åhall 2024-05-27 20:03:25 +02:00
parent 6629b834fd
commit f77a65ff66

View File

@ -215,25 +215,25 @@ func entryDatapoint(w http.ResponseWriter, r *http.Request, sess *session.T) { /
logger.Debug("entry", "datapoint", dpoint, "value", value, "trigger", trigger, "result", out)
var problemID int
var problemState string
switch v := out.(type) {
case bool:
// Trigger returning true - a problem occurred
if v {
problemID, err = ProblemStart(trigger)
logger.Info("FOO", "problemID", problemID, "err==nil", err == nil)
if err != nil {
err = werr.Wrap(err).Log()
logger.Error("entry", "error", err)
}
problemState = "PROBLEM"
} else {
// A problem didn't occur.
problemID, err = ProblemClose(trigger)
logger.Info("FOO", "problemID", problemID, "err==nil", err == nil)
if err != nil {
err = werr.Wrap(err).Log()
logger.Error("entry", "error", err)
}
problemState = "OK"
}
// Has a change in problem state happened?
@ -244,7 +244,7 @@ func entryDatapoint(w http.ResponseWriter, r *http.Request, sess *session.T) { /
logger.Debug("notification", "trigger", trigger.ID, "state", "change")
}
err = notificationManager.Send(problemID, []byte(trigger.Name), func(notificationService *notification.Service, err error) {
err = notificationManager.Send(problemID, []byte(problemState+": "+trigger.Name), func(notificationService *notification.Service, err error) {
logger.Info(
"notification",
"service", (*notificationService).GetType(),