diff --git a/server/notification-providers/pumble.js b/server/notification-providers/pumble.js new file mode 100644 index 000000000..51ee579d2 --- /dev/null +++ b/server/notification-providers/pumble.js @@ -0,0 +1,51 @@ +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) { + // Test message + let data = { + "text": "Uptime Kuma Alert", + "attachments": [ + { + "title": "Test Alert", + "text": msg, + "color": "#5BDD8B" + } + ] + }; + + await axios.post(notification.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(notification.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..c577e0404 --- /dev/null +++ b/src/components/notifications/Pumble.vue @@ -0,0 +1,9 @@ + 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;