From 3c77451fa23ea14629e1a05c4543c0c391feb7b9 Mon Sep 17 00:00:00 2001 From: risqy Date: Tue, 1 Aug 2023 19:27:02 +0200 Subject: [PATCH] uptime kuma webhook status message --- scnserver/api/handler/message.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scnserver/api/handler/message.go b/scnserver/api/handler/message.go index ae41b09..b45fd68 100644 --- a/scnserver/api/handler/message.go +++ b/scnserver/api/handler/message.go @@ -337,6 +337,7 @@ func (h MessageHandler) UptimeKumaWebHook(g *gin.Context) ginresp.HTTPResponse { type uptimeKumaWebhookBody struct { Heartbeat *struct { Time string `json:"time"` + Status int `json:"status"` Msg string `json:"msg"` Timezone string `json:"timezone"` TimezoneOffset string `json:"timezoneOffset"` @@ -358,7 +359,7 @@ func (h MessageHandler) UptimeKumaWebHook(g *gin.Context) ginresp.HTTPResponse { return *httpErr } - title := fmt.Sprintf("[UptimeKuma] %v down!", b.Monitor.Name) + var title = "" var content = "" content += fmt.Sprintf("%v\n", b.Msg) @@ -368,6 +369,15 @@ func (h MessageHandler) UptimeKumaWebHook(g *gin.Context) ginresp.HTTPResponse { content += fmt.Sprintf("url: %v\n", b.Monitor.Url) } + if b.Heartbeat != nil { + statusString := "down" + + if b.Heartbeat.Status == 1 { + statusString = "up" + } + title = fmt.Sprintf("[UptimeKuma] %v %v!", b.Monitor.Name, statusString) + } + } if b.Heartbeat != nil {