diff --git a/server/notification-providers/ntfy.js b/server/notification-providers/ntfy.js new file mode 100644 index 00000000..21f358f6 --- /dev/null +++ b/server/notification-providers/ntfy.js @@ -0,0 +1,26 @@ +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 { + 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; diff --git a/server/notification.js b/server/notification.js index d0b6f40d..c457ed14 100644 --- a/server/notification.js +++ b/server/notification.js @@ -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"); @@ -52,6 +53,7 @@ class Notification { new Discord(), new Teams(), new Gotify(), + new Ntfy(), new Line(), new LunaSea(), new Feishu(), diff --git a/src/components/notifications/Ntfy.vue b/src/components/notifications/Ntfy.vue new file mode 100644 index 00000000..d9a83b49 --- /dev/null +++ b/src/components/notifications/Ntfy.vue @@ -0,0 +1,30 @@ + + + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 37beb24d..18c316a5 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -4,6 +4,7 @@ import Discord from "./Discord.vue"; import Webhook from "./Webhook.vue"; import Signal from "./Signal.vue"; import Gotify from "./Gotify.vue"; +import Ntfy from "./Ntfy.vue"; import Slack from "./Slack.vue"; import RocketChat from "./RocketChat.vue"; import Teams from "./Teams.vue"; @@ -46,6 +47,7 @@ const NotificationFormList = { "teams": Teams, "signal": Signal, "gotify": Gotify, + "ntfy": Ntfy, "slack": Slack, "rocket.chat": RocketChat, "pushover": Pushover,