From c697a47c9af53862b9bb33952d19452759a5baea Mon Sep 17 00:00:00 2001 From: JanK Date: Wed, 13 Nov 2024 18:20:02 +0100 Subject: [PATCH 1/3] Added Pumble Notification --- server/notification-providers/pumble.js | 52 +++++++++++++++++++++++++ server/notification.js | 4 +- src/components/NotificationDialog.vue | 3 +- src/components/notifications/Pumble.vue | 8 ++++ src/components/notifications/index.js | 2 + 5 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 server/notification-providers/pumble.js create mode 100644 src/components/notifications/Pumble.vue diff --git a/server/notification-providers/pumble.js b/server/notification-providers/pumble.js new file mode 100644 index 000000000..20087fd61 --- /dev/null +++ b/server/notification-providers/pumble.js @@ -0,0 +1,52 @@ +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."; + let webhookUrl = notification.pumblewebhookURL; + + try { + if (heartbeatJSON === null && monitorJSON === null) { + // Test message + let data = { + "text": "Uptime Kuma Alert", + "attachments": [ + { + "title": "Test Alert", + "text": msg, + "color": "#5BDD8B" + } + ] + }; + + await axios.post(webhookUrl, data); + return okMsg; + } + + let data = { + "text": "Uptime Kuma Alert", + "attachments": [ + { + "title": `${monitorJSON["name"]} is ${heartbeatJSON["status"] === UP ? "up" : "down"}`, + "text": heartbeatJSON["msg"], + "color": (heartbeatJSON["status"] === UP ? "#5BDD8B" : "#DC3645"), + } + ] + }; + + await axios.post(webhookUrl, data); + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = Pumble; diff --git a/server/notification.js b/server/notification.js index e7977eb4a..c5c5428bd 100644 --- a/server/notification.js +++ b/server/notification.js @@ -69,6 +69,7 @@ const Cellsynt = require("./notification-providers/cellsynt"); const Onesender = require("./notification-providers/onesender"); const Wpush = require("./notification-providers/wpush"); const SendGrid = require("./notification-providers/send-grid"); +const Pumble = require("./notification-providers/pumble"); class Notification { @@ -154,7 +155,8 @@ class Notification { new GtxMessaging(), new Cellsynt(), new Wpush(), - new SendGrid() + new SendGrid(), + new Pumble() ]; for (let item of list) { if (! item.name) { diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index f6d728029..90cb169a0 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -165,7 +165,8 @@ export default { "whapi": "WhatsApp (Whapi)", "gtxmessaging": "GtxMessaging", "Cellsynt": "Cellsynt", - "SendGrid": "SendGrid" + "SendGrid": "SendGrid", + "pumble": "Pumble", }; // Put notifications here if it's not supported in most regions or its documentation is not in English diff --git a/src/components/notifications/Pumble.vue b/src/components/notifications/Pumble.vue new file mode 100644 index 000000000..8206478f1 --- /dev/null +++ b/src/components/notifications/Pumble.vue @@ -0,0 +1,8 @@ + + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index efa2af5c4..4f63d2bfe 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -67,6 +67,7 @@ import Cellsynt from "./Cellsynt.vue"; import WPush from "./WPush.vue"; import SIGNL4 from "./SIGNL4.vue"; import SendGrid from "./SendGrid.vue"; +import Pumble from "./Pumble.vue"; /** * Manage all notification form. @@ -142,6 +143,7 @@ const NotificationFormList = { "Cellsynt": Cellsynt, "WPush": WPush, "SendGrid": SendGrid, + "pumble": Pumble }; export default NotificationFormList; From be2f4621d3584786eb97b7c59665c427db145c13 Mon Sep 17 00:00:00 2001 From: JanK Date: Sat, 16 Nov 2024 10:11:15 +0100 Subject: [PATCH 2/3] Renamed webhook, changed type to url, added link to Pumble Webhook Documentation --- src/components/notifications/Pumble.vue | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/notifications/Pumble.vue b/src/components/notifications/Pumble.vue index 8206478f1..c577e0404 100644 --- a/src/components/notifications/Pumble.vue +++ b/src/components/notifications/Pumble.vue @@ -1,8 +1,9 @@ - From a6188da3bca9cddfb5a2264b44d75bb4c1702291 Mon Sep 17 00:00:00 2001 From: JanK Date: Sat, 16 Nov 2024 10:11:46 +0100 Subject: [PATCH 3/3] inlined webhookURL --- server/notification-providers/pumble.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/server/notification-providers/pumble.js b/server/notification-providers/pumble.js index 20087fd61..51ee579d2 100644 --- a/server/notification-providers/pumble.js +++ b/server/notification-providers/pumble.js @@ -10,7 +10,6 @@ class Pumble extends NotificationProvider { */ async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { const okMsg = "Sent Successfully."; - let webhookUrl = notification.pumblewebhookURL; try { if (heartbeatJSON === null && monitorJSON === null) { @@ -26,7 +25,7 @@ class Pumble extends NotificationProvider { ] }; - await axios.post(webhookUrl, data); + await axios.post(notification.webhookURL, data); return okMsg; } @@ -41,7 +40,7 @@ class Pumble extends NotificationProvider { ] }; - await axios.post(webhookUrl, data); + await axios.post(notification.webhookURL, data); return okMsg; } catch (error) { this.throwGeneralAxiosError(error);