uptime kuma webhook optional fields
This commit is contained in:
parent
3a2733c1b6
commit
a497049c66
|
@ -335,14 +335,14 @@ func (h MessageHandler) UptimeKumaWebHook(g *gin.Context) ginresp.HTTPResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
type uptimeKumaWebhookBody struct {
|
type uptimeKumaWebhookBody struct {
|
||||||
Heartbeat struct {
|
Heartbeat *struct {
|
||||||
Time string `json:"time"`
|
Time string `json:"time"`
|
||||||
Msg string `json:"msg"`
|
Msg string `json:"msg"`
|
||||||
Timezone string `json:"timezone"`
|
Timezone string `json:"timezone"`
|
||||||
TimezoneOffset string `json:"timezoneOffset"`
|
TimezoneOffset string `json:"timezoneOffset"`
|
||||||
LocalDateTime string `json:"localDateTime"`
|
LocalDateTime string `json:"localDateTime"`
|
||||||
} `json:"heartbeat"`
|
} `json:"heartbeat"`
|
||||||
Monitor struct {
|
Monitor *struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Url *string `json:"url"`
|
Url *string `json:"url"`
|
||||||
} `json:"monitor"`
|
} `json:"monitor"`
|
||||||
|
@ -360,19 +360,24 @@ func (h MessageHandler) UptimeKumaWebHook(g *gin.Context) ginresp.HTTPResponse {
|
||||||
|
|
||||||
title := fmt.Sprintf("[UptimeKuma] %v down!", b.Monitor.Name)
|
title := fmt.Sprintf("[UptimeKuma] %v down!", b.Monitor.Name)
|
||||||
|
|
||||||
content := fmt.Sprintf("%v\n", b.Monitor.Name)
|
var content = ""
|
||||||
content += fmt.Sprintf("%v\n", b.Msg)
|
content += fmt.Sprintf("%v\n", b.Msg)
|
||||||
if b.Monitor.Url != nil {
|
if b.Monitor != nil {
|
||||||
content += fmt.Sprintf("url: %v\n", b.Monitor.Url)
|
content += fmt.Sprintf("%v\n", b.Monitor.Name)
|
||||||
|
if b.Monitor.Url != nil {
|
||||||
|
content += fmt.Sprintf("url: %v\n", b.Monitor.Url)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
content += "===== Heartbeat ======"
|
if b.Heartbeat != nil {
|
||||||
content += fmt.Sprintf("msg: %v\n", b.Heartbeat.Msg)
|
content += "===== Heartbeat ======"
|
||||||
content += fmt.Sprintf("timestamp: %v\n", b.Heartbeat.Time)
|
content += fmt.Sprintf("msg: %v\n", b.Heartbeat.Msg)
|
||||||
content += fmt.Sprintf("timezone: %v\n", b.Heartbeat.Timezone)
|
content += fmt.Sprintf("timestamp: %v\n", b.Heartbeat.Time)
|
||||||
content += fmt.Sprintf("timezone offset: %v\n", b.Heartbeat.TimezoneOffset)
|
content += fmt.Sprintf("timezone: %v\n", b.Heartbeat.Timezone)
|
||||||
content += fmt.Sprintf("local date time: %v\n", b.Heartbeat.TimezoneOffset)
|
content += fmt.Sprintf("timezone offset: %v\n", b.Heartbeat.TimezoneOffset)
|
||||||
|
content += fmt.Sprintf("local date time: %v\n", b.Heartbeat.TimezoneOffset)
|
||||||
|
}
|
||||||
okResp, errResp := h.sendMessageInternal(g, ctx, q.UserID, q.KeyToken, nil, &title, &content, langext.Ptr(1), nil, nil, nil)
|
okResp, errResp := h.sendMessageInternal(g, ctx, q.UserID, q.KeyToken, nil, &title, &content, langext.Ptr(1), nil, nil, nil)
|
||||||
|
|
||||||
if errResp != nil {
|
if errResp != nil {
|
||||||
|
|
Loading…
Reference in New Issue