From 74c584f544bb84c6f41f3d1f07bc5e6813d13fcf Mon Sep 17 00:00:00 2001 From: Arjun Komath Date: Fri, 21 Jan 2022 07:42:03 +0000 Subject: [PATCH 1/3] Add Push by Techulus --- .../notification-providers/techulus-push.js | 23 +++++++++++++++++++ server/notification.js | 3 +++ src/components/notifications/TechulusPush.vue | 20 ++++++++++++++++ src/components/notifications/index.js | 2 ++ src/languages/en.js | 1 + 5 files changed, 49 insertions(+) create mode 100644 server/notification-providers/techulus-push.js create mode 100644 src/components/notifications/TechulusPush.vue diff --git a/server/notification-providers/techulus-push.js b/server/notification-providers/techulus-push.js new file mode 100644 index 000000000..b6919da55 --- /dev/null +++ b/server/notification-providers/techulus-push.js @@ -0,0 +1,23 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); + +class TechulusPush extends NotificationProvider { + + name = "PushByTechulus"; + + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + let okMsg = "Sent Successfully."; + + try { + await axios.post(`https://push.techulus.com/api/v1/notify/${notification.pushAPIKey}`, { + "title": "Uptime-Kuma", + "body": msg + }) + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error) + } + } +} + +module.exports = TechulusPush; diff --git a/server/notification.js b/server/notification.js index 4d72c81c7..c66f175da 100644 --- a/server/notification.js +++ b/server/notification.js @@ -12,6 +12,7 @@ const ClickSendSMS = require("./notification-providers/clicksendsms"); const Pushbullet = require("./notification-providers/pushbullet"); const Pushover = require("./notification-providers/pushover"); const Pushy = require("./notification-providers/pushy"); +const TechulusPush = require("./notification-providers/techulus-push"); const RocketChat = require("./notification-providers/rocket-chat"); const Signal = require("./notification-providers/signal"); const Slack = require("./notification-providers/slack"); @@ -55,6 +56,7 @@ class Notification { new Pushbullet(), new Pushover(), new Pushy(), + new TechulusPush(), new RocketChat(), new Signal(), new Slack(), @@ -90,6 +92,7 @@ class Notification { * Throw Error with fail msg */ static async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + console.log("this.providerList[notification.type]", this.providerList[notification.type]) if (this.providerList[notification.type]) { return this.providerList[notification.type].send(notification, msg, monitorJSON, heartbeatJSON); } else { diff --git a/src/components/notifications/TechulusPush.vue b/src/components/notifications/TechulusPush.vue new file mode 100644 index 000000000..918f8be63 --- /dev/null +++ b/src/components/notifications/TechulusPush.vue @@ -0,0 +1,20 @@ + + + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 03945f90e..da21ee3f1 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -9,6 +9,7 @@ import RocketChat from "./RocketChat.vue"; import Teams from "./Teams.vue"; import Pushover from "./Pushover.vue"; import Pushy from "./Pushy.vue"; +import TechulusPush from "./TechulusPush.vue"; import Octopush from "./Octopush.vue"; import PromoSMS from "./PromoSMS.vue"; import ClickSendSMS from "./ClickSendSMS.vue"; @@ -44,6 +45,7 @@ const NotificationFormList = { "rocket.chat": RocketChat, "pushover": Pushover, "pushy": Pushy, + "PushByTechulus": TechulusPush, "octopush": Octopush, "promosms": PromoSMS, "clicksendsms": ClickSendSMS, diff --git a/src/languages/en.js b/src/languages/en.js index 47513466c..4acc59fad 100644 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -238,6 +238,7 @@ export default { "rocket.chat": "Rocket.Chat", pushover: "Pushover", pushy: "Pushy", + PushByTechulus: "Push by Techulus", octopush: "Octopush", promosms: "PromoSMS", clicksendsms: "ClickSend SMS", From 51b7a2badbf14f979b5c7bfa9422e908fea9e1a2 Mon Sep 17 00:00:00 2001 From: Arjun Komath Date: Fri, 21 Jan 2022 07:43:14 +0000 Subject: [PATCH 2/3] remove log --- server/notification.js | 1 - 1 file changed, 1 deletion(-) diff --git a/server/notification.js b/server/notification.js index c66f175da..69326794d 100644 --- a/server/notification.js +++ b/server/notification.js @@ -92,7 +92,6 @@ class Notification { * Throw Error with fail msg */ static async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { - console.log("this.providerList[notification.type]", this.providerList[notification.type]) if (this.providerList[notification.type]) { return this.providerList[notification.type].send(notification, msg, monitorJSON, heartbeatJSON); } else { From 23796723dd2b6be3623b925d0f9e74b63cab9262 Mon Sep 17 00:00:00 2001 From: Arjun Komath Date: Fri, 21 Jan 2022 20:42:08 +1100 Subject: [PATCH 3/3] Address code review Add missing comma Co-authored-by: Adam Stachowicz --- server/notification-providers/techulus-push.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/notification-providers/techulus-push.js b/server/notification-providers/techulus-push.js index b6919da55..f844d17ce 100644 --- a/server/notification-providers/techulus-push.js +++ b/server/notification-providers/techulus-push.js @@ -11,7 +11,7 @@ class TechulusPush extends NotificationProvider { try { await axios.post(`https://push.techulus.com/api/v1/notify/${notification.pushAPIKey}`, { "title": "Uptime-Kuma", - "body": msg + "body": msg, }) return okMsg; } catch (error) {