diff --git a/server/notification-providers/pinglet.js b/server/notification-providers/pinglet.js new file mode 100644 index 000000000..4c84bae8a --- /dev/null +++ b/server/notification-providers/pinglet.js @@ -0,0 +1,48 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); + +class Pinglet extends NotificationProvider { + name = "pinglet"; + + /** + * @inheritdoc + */ + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + const okMsg = "Sent Successfully."; + + try { + let publishUrl = notification.pingletPublishUrl; + if (publishUrl.endsWith("/")) { + publishUrl = publishUrl.slice(0, -1); + } + + const config = this.getAxiosConfigWithProxy({ + headers: { + Authorization: "Bearer " + notification.pingletApiKey, + }, + params: { + rewrite: "uptimekuma", + }, + }); + + // Pinglet's uptimekuma rewriter accepts Uptime Kuma's webhook payload + // as-is and maps it to a titled message with level and priority + // server-side, so this provider just forwards the raw shape. + await axios.post( + publishUrl, + { + heartbeat: heartbeatJSON, + monitor: monitorJSON, + msg, + }, + config + ); + + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = Pinglet; diff --git a/server/notification.js b/server/notification.js index 13e333e80..be47cd3c5 100644 --- a/server/notification.js +++ b/server/notification.js @@ -45,6 +45,7 @@ const Pumble = require("./notification-providers/pumble"); const FlashDuty = require("./notification-providers/flashduty"); const Flowtriq = require("./notification-providers/flowtriq"); const PagerTree = require("./notification-providers/pagertree"); +const Pinglet = require("./notification-providers/pinglet"); const Plivo = require("./notification-providers/plivo"); const PromoSMS = require("./notification-providers/promosms"); const Pushbullet = require("./notification-providers/pushbullet"); @@ -159,6 +160,7 @@ class Notification { new FlashDuty(), new Flowtriq(), new PagerTree(), + new Pinglet(), new Plivo(), new PromoSMS(), new Pumble(), diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index e602e9da1..67b106bbe 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -257,6 +257,7 @@ export default { lunasea: "LunaSea", notifery: "Notifery", ntfy: "Ntfy", + pinglet: "Pinglet", pushbullet: "Pushbullet", PushByTechulus: "Push by Techulus", pushover: "Pushover", diff --git a/src/components/notifications/Pinglet.vue b/src/components/notifications/Pinglet.vue new file mode 100644 index 000000000..dd9b986a4 --- /dev/null +++ b/src/components/notifications/Pinglet.vue @@ -0,0 +1,42 @@ + + + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 5de8b8461..9de95b8bf 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -44,6 +44,7 @@ import PagerDuty from "./PagerDuty.vue"; import FlashDuty from "./FlashDuty.vue"; import Flowtriq from "./Flowtriq.vue"; import PagerTree from "./PagerTree.vue"; +import Pinglet from "./Pinglet.vue"; import Plivo from "./Plivo.vue"; import PromoSMS from "./PromoSMS.vue"; import Pumble from "./Pumble.vue"; @@ -147,6 +148,7 @@ const NotificationFormList = { FlashDuty: FlashDuty, Flowtriq: Flowtriq, PagerTree: PagerTree, + pinglet: Pinglet, plivo: Plivo, promosms: PromoSMS, pumble: Pumble, diff --git a/src/lang/en.json b/src/lang/en.json index 722a536bf..6782382cf 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -1127,6 +1127,8 @@ "Flowtriq Webhook URL": "Webhook URL", "Flowtriq API Key": "API Key", "flowtriqApiKeyDescription": "Optional API key for authenticating webhook requests to your Flowtriq instance.", + "Pinglet Topic URL": "Topic URL", + "pingletTopicUrlDescription": "The publish URL of the Pinglet topic to send alerts to, e.g. https://app.pinglet.co.uk/your-namespace/alerts. The topic is created on first publish if it doesn't exist yet.", "nostrRelays": "Nostr relays", "nostrRelaysHelp": "One relay URL per line", "nostrSender": "Sender Private Key (nsec)",