diff --git a/README.md b/README.md index 9177cc998..4fd0ff0cf 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ Browse to http://localhost:3001 after starting. ### Advanced Installation -If you need more options or need to browse via a reserve proxy, please read: +If you need more options or need to browse via a reverse proxy, please read: https://github.com/louislam/uptime-kuma/wiki/%F0%9F%94%A7-How-to-Install diff --git a/package.json b/package.json index fdc690f75..801348266 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "url": "https://github.com/louislam/uptime-kuma.git" }, "engines": { - "node": "14.*" + "node": "14.* >=16.*" }, "scripts": { "install-legacy": "npm install --legacy-peer-deps", @@ -130,4 +130,4 @@ "typescript": "~4.4.4", "vite": "~2.6.14" } -} +} \ No newline at end of file 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 @@