add ntfy support

ref https://github.com/louislam/uptime-kuma/issues/1622
This commit is contained in:
Philipp Dormann
2022-05-23 10:32:36 +02:00
parent 6ae2a48584
commit 71f031c14e
4 changed files with 67 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
const NotificationProvider = require("./notification-provider");
const axios = require("axios");
class Ntfy extends NotificationProvider {
name = "ntfy";
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully.";
try {
if (notification.ntfyserverurl && notification.ntfyserverurl.endsWith("/")) {
notification.ntfyserverurl = notification.ntfyserverurl.slice(0, -1);
}
await axios.post(`${notification.ntfyserverurl}`, {
"topic": notification.ntfytopic,
"message": msg,
"priority": notification.ntfyPriority || 4,
"title": "Uptime-Kuma",
})
return okMsg;
} catch (error) {
this.throwGeneralAxiosError(error);
}
}
}
module.exports = Ntfy;

View File

@@ -2,6 +2,7 @@ const { R } = require("redbean-node");
const Apprise = require("./notification-providers/apprise");
const Discord = require("./notification-providers/discord");
const Gotify = require("./notification-providers/gotify");
const Ntfy = require("./notification-providers/ntfy");
const Line = require("./notification-providers/line");
const LunaSea = require("./notification-providers/lunasea");
const Mattermost = require("./notification-providers/mattermost");
@@ -51,6 +52,7 @@ class Notification {
new Discord(),
new Teams(),
new Gotify(),
new Ntfy(),
new Line(),
new LunaSea(),
new Feishu(),