diff --git a/server/notification-providers/signl4.js b/server/notification-providers/signl4.js new file mode 100644 index 00000000..e48983f5 --- /dev/null +++ b/server/notification-providers/signl4.js @@ -0,0 +1,52 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); +const { UP, DOWN } = require("../../src/util"); + +class SIGNL4 extends NotificationProvider { + name = "SIGNL4"; + + /** + * @inheritdoc + */ + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + const okMsg = "Sent Successfully."; + + try { + let data = { + heartbeat: heartbeatJSON, + monitor: monitorJSON, + msg, + // Source system + "X-S4-SourceSystem": "UptimeKuma", + monitorUrl: this.extractAdress(monitorJSON), + }; + + const config = { + headers: { + "Content-Type": "application/json" + } + }; + + if (heartbeatJSON == null) { + // Test alert + data.title = "Uptime Kuma Alert"; + data.message = msg; + } else if (heartbeatJSON.status === UP) { + data.title = "Uptime Kuma Monitor ✅ Up"; + data["X-S4-ExternalID"] = "UptimeKuma-" + monitorJSON.monitorID; + data["X-S4-Status"] = "resolved"; + } else if (heartbeatJSON.status === DOWN) { + data.title = "Uptime Kuma Monitor 🔴 Down"; + data["X-S4-ExternalID"] = "UptimeKuma-" + monitorJSON.monitorID; + data["X-S4-Status"] = "new"; + } + + await axios.post(notification.webhookURL, data, config); + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = SIGNL4; diff --git a/server/notification.js b/server/notification.js index 8fce5b90..60eae4d7 100644 --- a/server/notification.js +++ b/server/notification.js @@ -42,6 +42,7 @@ const Pushy = require("./notification-providers/pushy"); const RocketChat = require("./notification-providers/rocket-chat"); const SerwerSMS = require("./notification-providers/serwersms"); const Signal = require("./notification-providers/signal"); +const SIGNL4 = require("./notification-providers/signl4"); const Slack = require("./notification-providers/slack"); const SMSPartner = require("./notification-providers/smspartner"); const SMSEagle = require("./notification-providers/smseagle"); @@ -127,6 +128,7 @@ class Notification { new ServerChan(), new SerwerSMS(), new Signal(), + new SIGNL4(), new SMSManager(), new SMSPartner(), new Slack(), diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index c7ae1923..864cbf5f 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -145,6 +145,7 @@ export default { "pushy": "Pushy", "rocket.chat": "Rocket.Chat", "signal": "Signal", + "SIGNL4": "SIGNL4", "slack": "Slack", "squadcast": "SquadCast", "SMSEagle": "SMSEagle", diff --git a/src/components/notifications/SIGNL4.vue b/src/components/notifications/SIGNL4.vue new file mode 100644 index 00000000..eb014558 --- /dev/null +++ b/src/components/notifications/SIGNL4.vue @@ -0,0 +1,16 @@ + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 5ed5e70b..e5df6fe4 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -64,6 +64,7 @@ import SevenIO from "./SevenIO.vue"; import Whapi from "./Whapi.vue"; import Cellsynt from "./Cellsynt.vue"; import WPush from "./WPush.vue"; +import SIGNL4 from "./SIGNL4.vue"; /** * Manage all notification form. @@ -114,6 +115,7 @@ const NotificationFormList = { "rocket.chat": RocketChat, "serwersms": SerwerSMS, "signal": Signal, + "SIGNL4": SIGNL4, "SMSManager": SMSManager, "SMSPartner": SMSPartner, "slack": Slack, diff --git a/src/lang/en.json b/src/lang/en.json index c2e960d4..a09f0162 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -991,5 +991,8 @@ "Go back to home page.": "Go back to home page.", "No tags found.": "No tags found.", "Lost connection to the socket server.": "Lost connection to the socket server.", - "Cannot connect to the socket server.": "Cannot connect to the socket server." + "Cannot connect to the socket server.": "Cannot connect to the socket server.", + "SIGNL4": "SIGNL4", + "SIGNL4 Webhook URL": "SIGNL4 Webhook URL", + "signl4Docs": "You can find more information about how to configure SIGNL4 and how to obtain the SIGNL4 webhook URL in the {0}." }