From ab68c35ad6d132ace9dac4c0f3e72bec32597e1d Mon Sep 17 00:00:00 2001 From: vapao Date: Fri, 2 May 2025 14:38:20 +0800 Subject: [PATCH] Add SpugPush notification provider --- server/notification-providers/spugpush.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/server/notification-providers/spugpush.js b/server/notification-providers/spugpush.js index f6b203252..33b7c9686 100644 --- a/server/notification-providers/spugpush.js +++ b/server/notification-providers/spugpush.js @@ -1,5 +1,6 @@ const NotificationProvider = require("./notification-provider"); const axios = require("axios"); +const { DOWN, UP } = require("../../src/util"); class SpugPush extends NotificationProvider { @@ -11,16 +12,20 @@ class SpugPush extends NotificationProvider { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { let okMsg = "Sent Successfully."; try { - await axios.post(`https://push.spug.cc/send/${notification.templateKey}`, { - "status": heartbeatJSON["status"], - "msg": heartbeatJSON["msg"], - "duration": heartbeatJSON["duration"], - "name": monitorJSON["name"], - "target": this.extractAddress(monitorJSON), - }); + let formData = {msg} + const apiUrl = `https://push.spug.cc/send/${notification.templateKey}`; + if (heartbeatJSON == null) { + formData.title = "Uptime Kuma Message"; + } else if (heartbeatJSON["status"] === UP) { + formData.title = `UptimeKuma 「${monitorJSON["name"]}」 is Up`; + formData.msg = `[✅ Up] ${heartbeatJSON["msg"]}` + } else if (heartbeatJSON["status"] === DOWN) { + formData.title = `UptimeKuma 「${monitorJSON["name"]}」 is Down`; + formData.msg = `[🔴 Down] ${heartbeatJSON["msg"]}` + } + await axios.post(apiUrl, formData); return okMsg; - } catch (error) { this.throwGeneralAxiosError(error); }