diff --git a/server/notification-providers/pushover.js b/server/notification-providers/pushover.js index 77ef1a3f0..52d13eef7 100644 --- a/server/notification-providers/pushover.js +++ b/server/notification-providers/pushover.js @@ -7,12 +7,12 @@ class Pushover extends NotificationProvider { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { let okMsg = "Sent Successfully."; - let pushoverlink = "https://api.pushover.net/1/messages.json" + let pushoverlink = "https://api.pushover.net/1/messages.json"; try { if (heartbeatJSON == null) { let data = { - "message": "Uptime Kuma Pushover testing successful.", + "message": msg, "user": notification.pushoveruserkey, "token": notification.pushoverapptoken, "sound": notification.pushoversounds, @@ -21,8 +21,8 @@ class Pushover extends NotificationProvider { "retry": "30", "expire": "3600", "html": 1, - } - await axios.post(pushoverlink, data) + }; + await axios.post(pushoverlink, data); return okMsg; } @@ -36,11 +36,11 @@ class Pushover extends NotificationProvider { "retry": "30", "expire": "3600", "html": 1, - } - await axios.post(pushoverlink, data) + }; + await axios.post(pushoverlink, data); return okMsg; } catch (error) { - this.throwGeneralAxiosError(error) + this.throwGeneralAxiosError(error); } } diff --git a/server/notification-providers/serwersms.js b/server/notification-providers/serwersms.js new file mode 100644 index 000000000..14fe691a8 --- /dev/null +++ b/server/notification-providers/serwersms.js @@ -0,0 +1,44 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); + +class SerwerSMS extends NotificationProvider { + + name = "serwersms"; + + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + let okMsg = "Sent Successfully."; + + try { + let config = { + headers: { + "Content-Type": "application/json", + } + }; + let data = { + "username": notification.serwersmsUsername, + "password": notification.serwersmsPassword, + "phone": notification.serwersmsPhoneNumber, + "text": msg.replace(/[^\x00-\x7F]/g, ""), + "sender": notification.serwersmsSenderName, + }; + + let resp = await axios.post("https://api2.serwersms.pl/messages/send_sms", data, config); + + if (!resp.data.success) { + if (resp.data.error) { + let error = `SerwerSMS.pl API returned error code ${resp.data.error.code} (${resp.data.error.type}) with error message: ${resp.data.error.message}`; + this.throwGeneralAxiosError(error); + } else { + let error = "SerwerSMS.pl API returned an unexpected response"; + this.throwGeneralAxiosError(error); + } + } + + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = SerwerSMS; diff --git a/server/notification.js b/server/notification.js index 18c823b2b..e2cfb193d 100644 --- a/server/notification.js +++ b/server/notification.js @@ -23,6 +23,7 @@ const Feishu = require("./notification-providers/feishu"); const AliyunSms = require("./notification-providers/aliyun-sms"); const DingDing = require("./notification-providers/dingding"); const Bark = require("./notification-providers/bark"); +const SerwerSMS = require("./notification-providers/serwersms"); class Notification { @@ -58,6 +59,7 @@ class Notification { new Telegram(), new Webhook(), new Bark(), + new SerwerSMS(), ]; for (let item of list) { diff --git a/src/components/notifications/ClickSendSMS.vue b/src/components/notifications/ClickSendSMS.vue index 2aed4184b..4fbb2f414 100644 --- a/src/components/notifications/ClickSendSMS.vue +++ b/src/components/notifications/ClickSendSMS.vue @@ -3,7 +3,7 @@
{{ $t("apiCredentials") }} - here + {{ $t("here") }}
diff --git a/src/components/notifications/SMTP.vue b/src/components/notifications/SMTP.vue index 483917e3f..ab660abed 100644 --- a/src/components/notifications/SMTP.vue +++ b/src/components/notifications/SMTP.vue @@ -10,7 +10,7 @@
- + +