mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-24 22:14:47 +02:00
8a92054c2b
* Added JSDoc to eslint rules Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com> * Fixed JSDoc eslint errors Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com> * Update the check-linters workflow to Node.js 20 --------- Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com> Co-authored-by: Louis Lam <louislam@users.noreply.github.com>
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
const NotificationProvider = require("./notification-provider");
|
|
const axios = require("axios");
|
|
const { UP } = require("../../src/util");
|
|
|
|
class GoAlert extends NotificationProvider {
|
|
|
|
name = "GoAlert";
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
|
let okMsg = "Sent Successfully.";
|
|
try {
|
|
let closeAction = "close";
|
|
let data = {
|
|
summary: msg,
|
|
};
|
|
if (heartbeatJSON != null && heartbeatJSON["status"] === UP) {
|
|
data["action"] = closeAction;
|
|
}
|
|
let headers = {
|
|
"Content-Type": "multipart/form-data",
|
|
};
|
|
let config = {
|
|
headers: headers
|
|
};
|
|
await axios.post(`${notification.goAlertBaseURL}/api/v2/generic/incoming?token=${notification.goAlertToken}`, data, config);
|
|
return okMsg;
|
|
|
|
} catch (error) {
|
|
let msg = (error.response.data) ? error.response.data : "Error without response";
|
|
throw new Error(msg);
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = GoAlert;
|