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.js b/server/notification.js index 0c222d932..57bc310ce 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"); @@ -126,6 +127,7 @@ class Notification { new FlashDuty(), new PagerTree(), new PromoSMS(), + new Pumble(), new Pushbullet(), new PushDeer(), new Pushover(), diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index 56cae66c8..fa1bbefb2 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", 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 cbd6f2b68..090b70cd5 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -36,6 +36,7 @@ import PagerDuty from "./PagerDuty.vue"; import FlashDuty from "./FlashDuty.vue"; import PagerTree from "./PagerTree.vue"; import PromoSMS from "./PromoSMS.vue"; +import Pumble from "./Pumble.vue"; import Pushbullet from "./Pushbullet.vue"; import PushDeer from "./PushDeer.vue"; import Pushover from "./Pushover.vue"; @@ -113,6 +114,7 @@ const NotificationFormList = { "FlashDuty": FlashDuty, "PagerTree": PagerTree, "promosms": PromoSMS, + "pumble": Pumble, "pushbullet": Pushbullet, "PushByTechulus": TechulusPush, "PushDeer": PushDeer,