mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-30 18:24:03 +00:00
goalert notification provider added
This commit is contained in:
parent
04fc124928
commit
65e6921a41
2 changed files with 34 additions and 0 deletions
32
server/notification-providers/goalert.js
Normal file
32
server/notification-providers/goalert.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
const NotificationProvider = require("./notification-provider");
|
||||
const axios = require("axios");
|
||||
const { UP } = require("../../src/util");
|
||||
|
||||
class GoAlert extends NotificationProvider {
|
||||
|
||||
name = "goalert";
|
||||
|
||||
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||
let okMsg = "Sent Successfully.";
|
||||
let closeAction = "close";
|
||||
let parameters = {
|
||||
token: notification.goAlertToken,
|
||||
summary: msg,
|
||||
}
|
||||
if (heartbeatJSON["status"] === UP) {
|
||||
parameters["action"] = closeAction;
|
||||
}
|
||||
try {
|
||||
await axios.get(`${notification.goAlertBaseURL}/api/v2/generic/incoming`, {
|
||||
params: parameters,
|
||||
});
|
||||
return okMsg;
|
||||
|
||||
} catch (error) {
|
||||
let msg = (error.response.data) ? error.response.data : "Error without response";
|
||||
throw new Error(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = GoAlert;
|
|
@ -38,6 +38,7 @@ const TechulusPush = require("./notification-providers/techulus-push");
|
|||
const Telegram = require("./notification-providers/telegram");
|
||||
const Webhook = require("./notification-providers/webhook");
|
||||
const WeCom = require("./notification-providers/wecom");
|
||||
const GoAlert = require("./notification-providers/goalert")
|
||||
|
||||
class Notification {
|
||||
|
||||
|
@ -88,6 +89,7 @@ class Notification {
|
|||
new Telegram(),
|
||||
new Webhook(),
|
||||
new WeCom(),
|
||||
new GoAlert(),
|
||||
];
|
||||
|
||||
for (let item of list) {
|
||||
|
|
Loading…
Reference in a new issue