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 {
|
||||
Heartbeat struct {
|
||||
Heartbeat *struct {
|
||||
Time string `json:"time"`
|
||||
Msg string `json:"msg"`
|
||||
Timezone string `json:"timezone"`
|
||||
TimezoneOffset string `json:"timezoneOffset"`
|
||||
LocalDateTime string `json:"localDateTime"`
|
||||
} `json:"heartbeat"`
|
||||
Monitor struct {
|
||||
Monitor *struct {
|
||||
Name string `json:"name"`
|
||||
Url *string `json:"url"`
|
||||
} `json:"monitor"`
|
||||
|
@ -360,19 +360,24 @@ func (h MessageHandler) UptimeKumaWebHook(g *gin.Context) ginresp.HTTPResponse {
|
|||
|
||||
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)
|
||||
if b.Monitor.Url != nil {
|
||||
content += fmt.Sprintf("url: %v\n", b.Monitor.Url)
|
||||
if b.Monitor != nil {
|
||||
content += fmt.Sprintf("%v\n", b.Monitor.Name)
|
||||
if b.Monitor.Url != nil {
|
||||
content += fmt.Sprintf("url: %v\n", b.Monitor.Url)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
content += "===== Heartbeat ======"
|
||||
content += fmt.Sprintf("msg: %v\n", b.Heartbeat.Msg)
|
||||
content += fmt.Sprintf("timestamp: %v\n", b.Heartbeat.Time)
|
||||
content += fmt.Sprintf("timezone: %v\n", b.Heartbeat.Timezone)
|
||||
content += fmt.Sprintf("timezone offset: %v\n", b.Heartbeat.TimezoneOffset)
|
||||
content += fmt.Sprintf("local date time: %v\n", b.Heartbeat.TimezoneOffset)
|
||||
|
||||
if b.Heartbeat != nil {
|
||||
content += "===== Heartbeat ======"
|
||||
content += fmt.Sprintf("msg: %v\n", b.Heartbeat.Msg)
|
||||
content += fmt.Sprintf("timestamp: %v\n", b.Heartbeat.Time)
|
||||
content += fmt.Sprintf("timezone: %v\n", b.Heartbeat.Timezone)
|
||||
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)
|
||||
|
||||
if errResp != nil {
|
||||
|
|
Loading…
Reference in New Issue