You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
999 B
34 lines
999 B
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.post(`${notification.goAlertBaseURL}/api/v2/generic/incoming`, {
|
|
params: parameters,
|
|
});
|
|
return okMsg;
|
|
|
|
} catch (error) {
|
|
let msg = (error.response.data) ? error.response.data : "Error without response";
|
|
console.log(error)
|
|
throw new Error(msg);
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = GoAlert;
|