New Notification Provider SIGNL4 (#5058)

Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
Ron 2024-08-28 23:18:25 +02:00 committed by GitHub
parent 3d9bbe1a62
commit 716832b9f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 77 additions and 1 deletions

View File

@ -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;

View File

@ -42,6 +42,7 @@ const Pushy = require("./notification-providers/pushy");
const RocketChat = require("./notification-providers/rocket-chat"); const RocketChat = require("./notification-providers/rocket-chat");
const SerwerSMS = require("./notification-providers/serwersms"); const SerwerSMS = require("./notification-providers/serwersms");
const Signal = require("./notification-providers/signal"); const Signal = require("./notification-providers/signal");
const SIGNL4 = require("./notification-providers/signl4");
const Slack = require("./notification-providers/slack"); const Slack = require("./notification-providers/slack");
const SMSPartner = require("./notification-providers/smspartner"); const SMSPartner = require("./notification-providers/smspartner");
const SMSEagle = require("./notification-providers/smseagle"); const SMSEagle = require("./notification-providers/smseagle");
@ -127,6 +128,7 @@ class Notification {
new ServerChan(), new ServerChan(),
new SerwerSMS(), new SerwerSMS(),
new Signal(), new Signal(),
new SIGNL4(),
new SMSManager(), new SMSManager(),
new SMSPartner(), new SMSPartner(),
new Slack(), new Slack(),

View File

@ -145,6 +145,7 @@ export default {
"pushy": "Pushy", "pushy": "Pushy",
"rocket.chat": "Rocket.Chat", "rocket.chat": "Rocket.Chat",
"signal": "Signal", "signal": "Signal",
"SIGNL4": "SIGNL4",
"slack": "Slack", "slack": "Slack",
"squadcast": "SquadCast", "squadcast": "SquadCast",
"SMSEagle": "SMSEagle", "SMSEagle": "SMSEagle",

View File

@ -0,0 +1,16 @@
<template>
<div class="mb-3">
<label for="signl4-webhook-url" class="form-label">{{ $t("SIGNL4 Webhook URL") }}</label>
<input
id="signl4-webhook-url"
v-model="$parent.notification.webhookURL"
type="url"
pattern="https?://.+"
class="form-control"
required
/>
<i18n-t tag="div" keypath="signl4Docs" class="form-text">
<a href="https://docs.signl4.com/integrations/uptime-kuima/uptime-kuma.html" target="_blank">SIGNL4 Docs</a>
</i18n-t>
</div>
</template>

View File

@ -64,6 +64,7 @@ import SevenIO from "./SevenIO.vue";
import Whapi from "./Whapi.vue"; import Whapi from "./Whapi.vue";
import Cellsynt from "./Cellsynt.vue"; import Cellsynt from "./Cellsynt.vue";
import WPush from "./WPush.vue"; import WPush from "./WPush.vue";
import SIGNL4 from "./SIGNL4.vue";
/** /**
* Manage all notification form. * Manage all notification form.
@ -114,6 +115,7 @@ const NotificationFormList = {
"rocket.chat": RocketChat, "rocket.chat": RocketChat,
"serwersms": SerwerSMS, "serwersms": SerwerSMS,
"signal": Signal, "signal": Signal,
"SIGNL4": SIGNL4,
"SMSManager": SMSManager, "SMSManager": SMSManager,
"SMSPartner": SMSPartner, "SMSPartner": SMSPartner,
"slack": Slack, "slack": Slack,

View File

@ -991,5 +991,8 @@
"Go back to home page.": "Go back to home page.", "Go back to home page.": "Go back to home page.",
"No tags found.": "No tags found.", "No tags found.": "No tags found.",
"Lost connection to the socket server.": "Lost connection to the socket server.", "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}."
} }