mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-24 15:24:05 +00:00
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
const NotificationProvider = require("./notification-provider");
|
|
const axios = require("axios");
|
|
|
|
class Keep extends NotificationProvider {
|
|
name = "Keep";
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
|
const okMsg = "Sent Successfully.";
|
|
|
|
try {
|
|
let data = {
|
|
heartbeat: heartbeatJSON,
|
|
monitor: monitorJSON,
|
|
msg,
|
|
};
|
|
let config = {
|
|
headers: {
|
|
"x-api-key": notification.webhookAPIKey,
|
|
"content-type": "application/json",
|
|
},
|
|
};
|
|
|
|
let url = notification.webhookURL;
|
|
|
|
if (url.endsWith("/")) {
|
|
url = url.slice(0, -1);
|
|
}
|
|
|
|
let webhookURL = url + "/alerts/event/uptimekuma";
|
|
|
|
await axios.post(webhookURL, data, config);
|
|
return okMsg;
|
|
} catch (error) {
|
|
this.throwGeneralAxiosError(error);
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = Keep;
|