1
0
mirror of https://github.com/louislam/uptime-kuma.git synced 2024-12-22 22:13:20 +02:00
uptime-kuma/server/notification-providers/signl4.js
Dj Isaac 019702f8e5
Some checks failed
Auto Test / check-linters (push) Failing after 38s
Auto Test / auto-test (18, ARM64) (push) Has been skipped
Auto Test / auto-test (18, macos-latest) (push) Has been skipped
Auto Test / auto-test (18, ubuntu-latest) (push) Has been skipped
Auto Test / auto-test (18, windows-latest) (push) Has been skipped
Auto Test / auto-test (20, ARM64) (push) Has been skipped
Auto Test / auto-test (20, macos-latest) (push) Has been skipped
Auto Test / auto-test (20, ubuntu-latest) (push) Has been skipped
Auto Test / auto-test (20, windows-latest) (push) Has been skipped
CodeQL / Analyze (go) (push) Failing after 23s
CodeQL / Analyze (javascript-typescript) (push) Failing after 20s
Merge Conflict Labeler / Labeling (push) Has been skipped
json-yaml-validate / json-yaml-validate (push) Successful in 8s
Auto Test / armv7-simple-test (18, ARMv7) (push) Has been cancelled
Auto Test / armv7-simple-test (20, ARMv7) (push) Has been cancelled
Auto Test / e2e-test (push) Has been cancelled
Automatically close stale issues / stale (push) Successful in 7s
fix: misspelling of 'address' (#5180)
2024-10-10 01:24:32 +02:00

53 lines
1.7 KiB
JavaScript

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;