mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-08 14:23:22 +08:00
add ntfy support
ref https://github.com/louislam/uptime-kuma/issues/1622
This commit is contained in:
29
server/notification-providers/ntfy.js
Normal file
29
server/notification-providers/ntfy.js
Normal 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;
|
@@ -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(),
|
||||
|
Reference in New Issue
Block a user