summaryrefslogtreecommitdiffstats
path: root/server/notification-providers/signl4.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel@debian.org>2024-11-26 09:28:28 +0100
committerDaniel Baumann <daniel@debian.org>2024-11-26 12:25:58 +0100
commita1882b67c41fe9901a0cd8059b5cc78a5beadec0 (patch)
tree2a24507c67aa99a15416707b2f7e645142230ed8 /server/notification-providers/signl4.js
parentInitial commit. (diff)
downloaduptime-kuma-a1882b67c41fe9901a0cd8059b5cc78a5beadec0.tar.xz
uptime-kuma-a1882b67c41fe9901a0cd8059b5cc78a5beadec0.zip
Adding upstream version 2.0.0~beta.0+dfsg.upstream/2.0.0_beta.0+dfsgupstream
Signed-off-by: Daniel Baumann <daniel@debian.org>
Diffstat (limited to 'server/notification-providers/signl4.js')
-rw-r--r--server/notification-providers/signl4.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/server/notification-providers/signl4.js b/server/notification-providers/signl4.js
new file mode 100644
index 0000000..8261a73
--- /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.extractAddress(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;