mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-28 06:59:42 -08:00
019702f8e5
Some checks are pending
Auto Test / auto-test (18, ARM64) (push) Blocked by required conditions
Auto Test / auto-test (18, macos-latest) (push) Blocked by required conditions
Auto Test / auto-test (18, ubuntu-latest) (push) Blocked by required conditions
Auto Test / auto-test (18, windows-latest) (push) Blocked by required conditions
Auto Test / auto-test (20, ARM64) (push) Blocked by required conditions
Auto Test / auto-test (20, macos-latest) (push) Blocked by required conditions
Auto Test / auto-test (20, ubuntu-latest) (push) Blocked by required conditions
Auto Test / auto-test (20, windows-latest) (push) Blocked by required conditions
Auto Test / armv7-simple-test (18, ARMv7) (push) Waiting to run
Auto Test / armv7-simple-test (20, ARMv7) (push) Waiting to run
Auto Test / check-linters (push) Waiting to run
Auto Test / e2e-test (push) Waiting to run
CodeQL / Analyze (go) (push) Waiting to run
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
Merge Conflict Labeler / Labeling (push) Waiting to run
json-yaml-validate / json-yaml-validate (push) Waiting to run
53 lines
1.7 KiB
JavaScript
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;
|