uptime kuma webhook status message

This commit is contained in:
Julian Graf 2023-08-01 19:27:02 +02:00
parent a497049c66
commit 3c77451fa2
1 changed files with 11 additions and 1 deletions

View File

@ -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 {