mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-08 06:29:57 +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;
|
Reference in New Issue
Block a user