diff --git a/server/notification-providers/notifery.js b/server/notification-providers/notifery.js new file mode 100644 index 000000000..772556497 --- /dev/null +++ b/server/notification-providers/notifery.js @@ -0,0 +1,53 @@ +const { getMonitorRelativeURL, UP } = require("../../src/util"); +const { setting } = require("../util-server"); +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); + +class Notifery extends NotificationProvider { + name = "notifery"; + + /** + * @inheritdoc + */ + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + const okMsg = "Sent Successfully."; + const url = "https://api.notifery.com/event"; + + let data = { + title: notification.notiferyTitle || "Uptime Kuma Alert", + message: msg, + }; + + if (notification.notiferyGroup) { + data.group = notification.notiferyGroup; + } + + // Link to the monitor + const baseURL = await setting("primaryBaseURL"); + if (baseURL && monitorJSON) { + data.message += `\n\nMonitor: ${baseURL}${getMonitorRelativeURL(monitorJSON.id)}`; + } + + if (heartbeatJSON) { + data.code = heartbeatJSON.status === UP ? 0 : 1; + + if (heartbeatJSON.ping) { + data.duration = heartbeatJSON.ping; + } + } + + try { + const headers = { + "Content-Type": "application/json", + "x-api-key": notification.notiferyApiKey, + }; + + await axios.post(url, data, { headers }); + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = Notifery; diff --git a/server/notification.js b/server/notification.js index 468d026c0..fd8c23d67 100644 --- a/server/notification.js +++ b/server/notification.js @@ -13,6 +13,7 @@ const DingDing = require("./notification-providers/dingding"); const Discord = require("./notification-providers/discord"); const Elks = require("./notification-providers/46elks"); const Feishu = require("./notification-providers/feishu"); +const Notifery = require("./notification-providers/notifery"); const FreeMobile = require("./notification-providers/freemobile"); const GoogleChat = require("./notification-providers/google-chat"); const Gorush = require("./notification-providers/gorush"); @@ -169,6 +170,7 @@ class Notification { new YZJ(), new SMSPlanet(), new SpugPush(), + new Notifery(), ]; for (let item of list) { if (! item.name) { diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index 2e66de8e9..acfcde6a2 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -168,7 +168,8 @@ export default { "waha": "WhatsApp (WAHA)", "gtxmessaging": "GtxMessaging", "Cellsynt": "Cellsynt", - "SendGrid": "SendGrid" + "SendGrid": "SendGrid", + "notifery": "Notifery" }; // Put notifications here if it's not supported in most regions or its documentation is not in English diff --git a/src/components/notifications/Notifery.vue b/src/components/notifications/Notifery.vue new file mode 100644 index 000000000..ce204dc6a --- /dev/null +++ b/src/components/notifications/Notifery.vue @@ -0,0 +1,49 @@ + + + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index be7feb820..933139a4a 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -4,6 +4,7 @@ import AliyunSMS from "./AliyunSms.vue"; import Apprise from "./Apprise.vue"; import Bark from "./Bark.vue"; import Bitrix24 from "./Bitrix24.vue"; +import Notifery from "./Notifery.vue"; import ClickSendSMS from "./ClickSendSMS.vue"; import CallMeBot from "./CallMeBot.vue"; import SMSC from "./SMSC.vue"; @@ -149,6 +150,7 @@ const NotificationFormList = { "ZohoCliq": ZohoCliq, "SevenIO": SevenIO, "whapi": Whapi, + "notifery": Notifery, "waha": WAHA, "gtxmessaging": GtxMessaging, "Cellsynt": Cellsynt,