From 1c3da995e31038d48bc3d9a18b201be9b62457fa Mon Sep 17 00:00:00 2001 From: jakubenglicky Date: Thu, 15 Sep 2022 09:11:05 +0200 Subject: [PATCH 1/2] Add support notification via SMSManager --- server/notification-providers/smsmanager.js | 25 +++++++++++++++++ server/notification.js | 2 ++ src/components/notifications/SMSManager.vue | 31 +++++++++++++++++++++ src/components/notifications/index.js | 2 ++ src/languages/cs-CZ.js | 3 ++ 5 files changed, 63 insertions(+) create mode 100644 server/notification-providers/smsmanager.js create mode 100644 src/components/notifications/SMSManager.vue diff --git a/server/notification-providers/smsmanager.js b/server/notification-providers/smsmanager.js new file mode 100644 index 000000000..833bff60f --- /dev/null +++ b/server/notification-providers/smsmanager.js @@ -0,0 +1,25 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); + +class SMSManager extends NotificationProvider { + + name = "SMSManager"; + + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + try { + let data = { + apikey: notification.smsmanagerApiKey, + endpoint: "https://http-api.smsmanager.cz/Send", + message: msg.replace(/[^\x00-\x7F]/g, ""), + to: notification.numbers, + messageType: notification.messageType, + }; + await axios.get(`${data.endpoint}?apikey=${data.apikey}&message=${data.message}&number=${data.to}&gateway=${data.messageType}`); + return "SMS sent sucessfully."; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = SMSManager; diff --git a/server/notification.js b/server/notification.js index 3306a53ac..6f71783b1 100644 --- a/server/notification.js +++ b/server/notification.js @@ -39,6 +39,7 @@ const Telegram = require("./notification-providers/telegram"); const Webhook = require("./notification-providers/webhook"); const WeCom = require("./notification-providers/wecom"); const GoAlert = require("./notification-providers/goalert"); +const SMSManager = require("./notification-providers/smsmanager"); class Notification { @@ -81,6 +82,7 @@ class Notification { new RocketChat(), new SerwerSMS(), new Signal(), + new SMSManager(), new Slack(), new SMTP(), new Stackfield(), diff --git a/src/components/notifications/SMSManager.vue b/src/components/notifications/SMSManager.vue new file mode 100644 index 000000000..25db624fc --- /dev/null +++ b/src/components/notifications/SMSManager.vue @@ -0,0 +1,31 @@ + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index e5570c80a..07ed2cd1a 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -28,6 +28,7 @@ import Pushy from "./Pushy.vue"; import RocketChat from "./RocketChat.vue"; import SerwerSMS from "./SerwerSMS.vue"; import Signal from "./Signal.vue"; +import SMSManager from "./SMSManager.vue"; import Slack from "./Slack.vue"; import Stackfield from "./Stackfield.vue"; import STMP from "./SMTP.vue"; @@ -75,6 +76,7 @@ const NotificationFormList = { "rocket.chat": RocketChat, "serwersms": SerwerSMS, "signal": Signal, + "SMSManager": SMSManager, "slack": Slack, "smtp": STMP, "stackfield": Stackfield, diff --git a/src/languages/cs-CZ.js b/src/languages/cs-CZ.js index b2b9331a4..c71075be7 100644 --- a/src/languages/cs-CZ.js +++ b/src/languages/cs-CZ.js @@ -576,4 +576,7 @@ export default { "Then choose an action, for example switch the scene to where an RGB light is red.": "Následně vyberte akci, například přepnutí scény z RGB světla na červenou.", "Frontend Version": "Verze frontendu", "Frontend Version do not match backend version!": "Verze frontendu neodpovídá verzi backendu!", + "You can divide numbers with": "Čísla můžete rozdělit pomocí ", + "or": "nebo", + "Gateway Type": "Typ brány", }; From 2d5096317fa3a90cfcb6618b6cc19bf305188d41 Mon Sep 17 00:00:00 2001 From: jakubenglicky Date: Thu, 15 Sep 2022 09:11:27 +0200 Subject: [PATCH 2/2] Fix warning at goalert.js --- server/notification-providers/goalert.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/notification-providers/goalert.js b/server/notification-providers/goalert.js index c757e5998..73e0375ac 100644 --- a/server/notification-providers/goalert.js +++ b/server/notification-providers/goalert.js @@ -22,7 +22,7 @@ class GoAlert extends NotificationProvider { let config = { headers: headers }; - let resp = await axios.post(`${notification.goAlertBaseURL}/api/v2/generic/incoming?token=${notification.goAlertToken}`, data, config); + await axios.post(`${notification.goAlertBaseURL}/api/v2/generic/incoming?token=${notification.goAlertToken}`, data, config); return okMsg; } catch (error) {