diff --git a/server/notification-providers/pumble.js b/server/notification-providers/pumble.js new file mode 100644 index 000000000..e1731c0ab --- /dev/null +++ b/server/notification-providers/pumble.js @@ -0,0 +1,48 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); +const { UP } = require("../../src/util"); + +class Pumble extends NotificationProvider { + name = "pumble"; + + /** + * @inheritDoc + */ + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + const okMsg = "Sent Successfully."; + + try { + if (heartbeatJSON === null && monitorJSON === null) { + let data = { + "attachments": [ + { + "title": "Uptime Kuma Alert", + "text": msg, + "color": "#5BDD8B" + } + ] + }; + + await axios.post(notification.webhookURL, data); + return okMsg; + } + + let data = { + "attachments": [ + { + "title": `${monitorJSON["name"]} is ${heartbeatJSON["status"] === UP ? "up" : "down"}`, + "text": heartbeatJSON["msg"], + "color": (heartbeatJSON["status"] === UP ? "#5BDD8B" : "#DC3645"), + } + ] + }; + + await axios.post(notification.webhookURL, data); + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = Pumble; diff --git a/server/notification-providers/pushover.js b/server/notification-providers/pushover.js index 8422b64c2..fdceeaa44 100644 --- a/server/notification-providers/pushover.js +++ b/server/notification-providers/pushover.js @@ -1,5 +1,6 @@ const { getMonitorRelativeURL } = require("../../src/util"); const { setting } = require("../util-server"); +const { UP } = require("../../src/util"); const NotificationProvider = require("./notification-provider"); const axios = require("axios"); @@ -43,15 +44,20 @@ class Pushover extends NotificationProvider { if (heartbeatJSON == null) { await axios.post(url, data); return okMsg; - } else { - data.message += `\nTime (${heartbeatJSON["timezone"]}):${heartbeatJSON["localDateTime"]}`; - await axios.post(url, data); - return okMsg; } + + if (heartbeatJSON.status === UP && notification.pushoversounds_up) { + // default = DOWN => DOWN-sound is also played for non-UP/DOWN notiifcations + data.sound = notification.pushoversounds_up; + } + + data.message += `\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`; + await axios.post(url, data); + return okMsg; + } catch (error) { this.throwGeneralAxiosError(error); } - } } diff --git a/server/notification-providers/sms-planet.js b/server/notification-providers/sms-planet.js new file mode 100644 index 000000000..97e9e715e --- /dev/null +++ b/server/notification-providers/sms-planet.js @@ -0,0 +1,40 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); + +class SMSPlanet extends NotificationProvider { + name = "SMSPlanet"; + + /** + * @inheritdoc + */ + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + const okMsg = "Sent Successfully."; + const url = "https://api2.smsplanet.pl/sms"; + + try { + let config = { + headers: { + "Authorization": "Bearer " + notification.smsplanetApiToken, + "content-type": "multipart/form-data" + } + }; + + let data = { + "from": notification.smsplanetSenderName, + "to": notification.smsplanetPhoneNumbers, + "msg": msg.replace(/🔴/, "❌") + }; + + let response = await axios.post(url, data, config); + if (!response.data?.messageId) { + throw new Error(response.data?.errorMsg ?? "SMSPlanet server did not respond with the expected result"); + } + + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = SMSPlanet; diff --git a/server/notification.js b/server/notification.js index 0c222d932..8682e6f5c 100644 --- a/server/notification.js +++ b/server/notification.js @@ -33,6 +33,7 @@ const Octopush = require("./notification-providers/octopush"); const OneBot = require("./notification-providers/onebot"); const Opsgenie = require("./notification-providers/opsgenie"); const PagerDuty = require("./notification-providers/pagerduty"); +const Pumble = require("./notification-providers/pumble"); const FlashDuty = require("./notification-providers/flashduty"); const PagerTree = require("./notification-providers/pagertree"); const PromoSMS = require("./notification-providers/promosms"); @@ -72,6 +73,7 @@ const Onesender = require("./notification-providers/onesender"); const Wpush = require("./notification-providers/wpush"); const SendGrid = require("./notification-providers/send-grid"); const YZJ = require("./notification-providers/yzj"); +const SMSPlanet = require("./notification-providers/sms-planet"); class Notification { @@ -126,6 +128,7 @@ class Notification { new FlashDuty(), new PagerTree(), new PromoSMS(), + new Pumble(), new Pushbullet(), new PushDeer(), new Pushover(), @@ -160,7 +163,8 @@ class Notification { new Cellsynt(), new Wpush(), new SendGrid(), - new YZJ() + new YZJ(), + new SMSPlanet(), ]; for (let item of list) { if (! item.name) { diff --git a/server/routers/status-page-router.js b/server/routers/status-page-router.js index 893f57564..6e57451f1 100644 --- a/server/routers/status-page-router.js +++ b/server/routers/status-page-router.js @@ -89,7 +89,7 @@ router.get("/api/status-page/heartbeat/:slug", cache("1 minutes"), async (reques SELECT * FROM heartbeat WHERE monitor_id = ? ORDER BY time DESC - LIMIT 50 + LIMIT 100 `, [ monitorID, ]); diff --git a/src/components/MonitorListItem.vue b/src/components/MonitorListItem.vue index 93c1deab4..ce38086b9 100644 --- a/src/components/MonitorListItem.vue +++ b/src/components/MonitorListItem.vue @@ -14,7 +14,7 @@
-
+
@@ -26,7 +26,7 @@
-
+
diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index 56cae66c8..3ea3e23d4 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -140,6 +140,7 @@ export default { "Opsgenie": "Opsgenie", "PagerDuty": "PagerDuty", "PagerTree": "PagerTree", + "pumble": "Pumble", "pushbullet": "Pushbullet", "PushByTechulus": "Push by Techulus", "pushover": "Pushover", @@ -185,7 +186,8 @@ export default { "PushPlus": "PushPlus (推送加)", "smsc": "SMSC", "WPush": "WPush(wpush.cn)", - "YZJ": "YZJ (云之家自定义机器人)" + "YZJ": "YZJ (云之家自定义机器人)", + "SMSPlanet": "SMSPlanet.pl" }; // Sort by notification name diff --git a/src/components/PublicGroupList.vue b/src/components/PublicGroupList.vue index bacddbf13..38aca2957 100644 --- a/src/components/PublicGroupList.vue +++ b/src/components/PublicGroupList.vue @@ -33,7 +33,7 @@