mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-26 19:36:29 +03:00
Add support for Squadcast incoming webhook
This commit is contained in:
parent
c3eef28443
commit
4157c7d546
5 changed files with 87 additions and 0 deletions
76
server/notification-providers/squadcast.js
Normal file
76
server/notification-providers/squadcast.js
Normal file
|
@ -0,0 +1,76 @@
|
|||
const NotificationProvider = require("./notification-provider");
|
||||
const axios = require("axios");
|
||||
const { DOWN, UP } = require("../../src/util");
|
||||
|
||||
class Squadcast extends NotificationProvider {
|
||||
|
||||
name = "squadcast";
|
||||
|
||||
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||
let okMsg = "Sent Successfully.";
|
||||
|
||||
try {
|
||||
|
||||
let config = {};
|
||||
let data = {
|
||||
message: msg,
|
||||
description: '',
|
||||
tags: {},
|
||||
heartbeat: heartbeatJSON,
|
||||
source: 'uptime-kuma'
|
||||
}
|
||||
|
||||
if (heartbeatJSON !== null) {
|
||||
data.description = heartbeatJSON["msg"];
|
||||
data.event_id = heartbeatJSON["monitorID"];
|
||||
|
||||
if (heartbeatJSON["status"] === DOWN) {
|
||||
data.message = `${monitorJSON['name']} is DOWN`;
|
||||
data.status = "trigger";
|
||||
} else {
|
||||
data.message = `${monitorJSON['name']} is UP`;
|
||||
data.status = "resolve";
|
||||
}
|
||||
|
||||
let address;
|
||||
switch (monitorJSON["type"]) {
|
||||
case "ping":
|
||||
address = monitorJSON["hostname"];
|
||||
break;
|
||||
case "port":
|
||||
case "dns":
|
||||
case "steam":
|
||||
address = monitorJSON["hostname"];
|
||||
if (monitorJSON["port"]) {
|
||||
address += ":" + monitorJSON["port"];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
address = monitorJSON["url"];
|
||||
break;
|
||||
}
|
||||
|
||||
data.tags["AlertAddress"] = address;
|
||||
|
||||
monitorJSON["tags"].forEach(tag => {
|
||||
data.tags[tag["name"]] = {
|
||||
value: tag["value"]
|
||||
};
|
||||
if (tag["color"] !== null) {
|
||||
data.tags[tag["name"]]["color"] = tag["color"]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
await axios.post(notification.squadcastWebhookURL, data, config);
|
||||
return okMsg;
|
||||
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Squadcast;
|
|
@ -32,6 +32,7 @@ const SerwerSMS = require("./notification-providers/serwersms");
|
|||
const Signal = require("./notification-providers/signal");
|
||||
const Slack = require("./notification-providers/slack");
|
||||
const SMTP = require("./notification-providers/smtp");
|
||||
const Squadcast = require("./notification-providers/squadcast");
|
||||
const Stackfield = require("./notification-providers/stackfield");
|
||||
const Teams = require("./notification-providers/teams");
|
||||
const TechulusPush = require("./notification-providers/techulus-push");
|
||||
|
@ -87,6 +88,7 @@ class Notification {
|
|||
new SMSManager(),
|
||||
new Slack(),
|
||||
new SMTP(),
|
||||
new Squadcast(),
|
||||
new Stackfield(),
|
||||
new Teams(),
|
||||
new TechulusPush(),
|
||||
|
|
6
src/components/notifications/Squadcast.vue
Normal file
6
src/components/notifications/Squadcast.vue
Normal file
|
@ -0,0 +1,6 @@
|
|||
<template>
|
||||
<div class="mb-3">
|
||||
<label for="webhook-url" class="form-label">{{ $t("Post URL") }}</label>
|
||||
<input id="webhook-url" v-model="$parent.notification.squadcastWebhookURL" type="url" pattern="https?://.+" class="form-control" required>
|
||||
</div>
|
||||
</template>
|
|
@ -31,6 +31,7 @@ import SerwerSMS from "./SerwerSMS.vue";
|
|||
import Signal from "./Signal.vue";
|
||||
import SMSManager from "./SMSManager.vue";
|
||||
import Slack from "./Slack.vue";
|
||||
import Squadcast from "./Squadcast.vue";
|
||||
import Stackfield from "./Stackfield.vue";
|
||||
import STMP from "./SMTP.vue";
|
||||
import Teams from "./Teams.vue";
|
||||
|
@ -79,6 +80,7 @@ const NotificationFormList = {
|
|||
"signal": Signal,
|
||||
"SMSManager": SMSManager,
|
||||
"slack": Slack,
|
||||
"squadcast": Squadcast,
|
||||
"smtp": STMP,
|
||||
"stackfield": Stackfield,
|
||||
"teams": Teams,
|
||||
|
|
|
@ -582,4 +582,5 @@ export default {
|
|||
goAlert: "GoAlert",
|
||||
backupOutdatedWarning: "Deprecated: Since a lot of features added and this backup feature is a bit unmaintained, it cannot generate or restore a complete backup.",
|
||||
backupRecommend: "Please backup the volume or the data folder (./data/) directly instead.",
|
||||
squadcast: "Squadcast",
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue