mirror of https://github.com/louislam/uptime-kuma
				
				
				
			New Notification Provider SIGNL4 (#5058)
Co-authored-by: Frank Elsinga <frank@elsinga.de>pull/5078/head
							parent
							
								
									3d9bbe1a62
								
							
						
					
					
						commit
						716832b9f3
					
				| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			@ -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(),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -145,6 +145,7 @@ export default {
 | 
			
		|||
                "pushy": "Pushy",
 | 
			
		||||
                "rocket.chat": "Rocket.Chat",
 | 
			
		||||
                "signal": "Signal",
 | 
			
		||||
                "SIGNL4": "SIGNL4",
 | 
			
		||||
                "slack": "Slack",
 | 
			
		||||
                "squadcast": "SquadCast",
 | 
			
		||||
                "SMSEagle": "SMSEagle",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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>
 | 
			
		||||
| 
						 | 
				
			
			@ -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,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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}."
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue