2021-09-07 16:42:46 +02:00
|
|
|
const NotificationProvider = require("./notification-provider");
|
|
|
|
const axios = require("axios");
|
|
|
|
|
|
|
|
class Pushover extends NotificationProvider {
|
|
|
|
|
|
|
|
name = "pushover";
|
|
|
|
|
|
|
|
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
2021-10-05 21:40:59 +02:00
|
|
|
let okMsg = "Sent Successfully.";
|
2021-11-29 11:19:55 +02:00
|
|
|
let pushoverlink = "https://api.pushover.net/1/messages.json";
|
2021-09-07 16:42:46 +02:00
|
|
|
|
|
|
|
try {
|
|
|
|
if (heartbeatJSON == null) {
|
|
|
|
let data = {
|
2021-11-29 11:19:55 +02:00
|
|
|
"message": msg,
|
2021-09-07 16:42:46 +02:00
|
|
|
"user": notification.pushoveruserkey,
|
|
|
|
"token": notification.pushoverapptoken,
|
|
|
|
"sound": notification.pushoversounds,
|
|
|
|
"priority": notification.pushoverpriority,
|
|
|
|
"title": notification.pushovertitle,
|
|
|
|
"retry": "30",
|
|
|
|
"expire": "3600",
|
|
|
|
"html": 1,
|
2021-11-29 11:19:55 +02:00
|
|
|
};
|
|
|
|
await axios.post(pushoverlink, data);
|
2021-09-07 16:42:46 +02:00
|
|
|
return okMsg;
|
|
|
|
}
|
|
|
|
|
|
|
|
let data = {
|
|
|
|
"message": "<b>Uptime Kuma Alert</b>\n\n<b>Message</b>:" + msg + "\n<b>Time (UTC)</b>:" + heartbeatJSON["time"],
|
|
|
|
"user": notification.pushoveruserkey,
|
|
|
|
"token": notification.pushoverapptoken,
|
|
|
|
"sound": notification.pushoversounds,
|
|
|
|
"priority": notification.pushoverpriority,
|
|
|
|
"title": notification.pushovertitle,
|
|
|
|
"retry": "30",
|
|
|
|
"expire": "3600",
|
|
|
|
"html": 1,
|
2021-11-29 11:19:55 +02:00
|
|
|
};
|
|
|
|
await axios.post(pushoverlink, data);
|
2021-09-07 16:42:46 +02:00
|
|
|
return okMsg;
|
|
|
|
} catch (error) {
|
2021-11-29 11:19:55 +02:00
|
|
|
this.throwGeneralAxiosError(error);
|
2021-09-07 16:42:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Pushover;
|