mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-13 17:14:21 -08:00
43 lines
1.1 KiB
JavaScript
43 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;
|