diff --git a/package-lock.json b/package-lock.json index 100cdcd88..328b1d287 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "uptime-kuma", - "version": "2.0.0-dev", + "version": "2.0.0-beta.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "uptime-kuma", - "version": "2.0.0-dev", + "version": "2.0.0-beta.0", "license": "MIT", "dependencies": { "@grpc/grpc-js": "~1.8.22", diff --git a/server/notification-providers/ceredsms.js b/server/notification-providers/ceredsms.js new file mode 100644 index 000000000..3823cf0e2 --- /dev/null +++ b/server/notification-providers/ceredsms.js @@ -0,0 +1,45 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); + +class CeredSMS extends NotificationProvider { + + name = "ceredsms"; + + /** + * @inheritdoc + */ + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + let okMsg = "Sent Successfully."; + + try { + let config = { + headers: { + "Content-Type": "application/json", + } + }; + let data = { + "key": notification.ceredsmsApiKey, + "from": notification.ceredsmsSenderName, + "phone_number": notification.ceredsmsPhoneNumber, + "message": msg.replace(/[^\x00-\x7F]/g, "") + }; + + let resp = await axios.post("https://sms.cered.pl/api/send", data, config); + if (!resp.data.message_id) { + if (resp.data.message) { + let error = `CeredSMS.pl API returned error message: ${resp.data.error.message}`; + this.throwGeneralAxiosError(error); + } else { + let error = "CeredSMS.pl API returned an unexpected response"; + this.throwGeneralAxiosError(error); + } + } + + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = CeredSMS; diff --git a/server/notification.js b/server/notification.js index e7977eb4a..de14d67ad 100644 --- a/server/notification.js +++ b/server/notification.js @@ -69,6 +69,7 @@ const Cellsynt = require("./notification-providers/cellsynt"); const Onesender = require("./notification-providers/onesender"); const Wpush = require("./notification-providers/wpush"); const SendGrid = require("./notification-providers/send-grid"); +const CeredSMS = require("./notification-providers/ceredsms"); class Notification { @@ -154,7 +155,8 @@ class Notification { new GtxMessaging(), new Cellsynt(), new Wpush(), - new SendGrid() + new SendGrid(), + new CeredSMS() ]; for (let item of list) { if (! item.name) { diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index f6d728029..5d6c0fde2 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -183,6 +183,7 @@ export default { "ServerChan": "ServerChan (Serveré…±)", "smsc": "SMSC", "WPush": "WPush(wpush.cn)", + "ceredsms": "cered.pl", }; // Sort by notification name diff --git a/src/components/notifications/CeredSMS.vue b/src/components/notifications/CeredSMS.vue new file mode 100644 index 000000000..9eeb1a878 --- /dev/null +++ b/src/components/notifications/CeredSMS.vue @@ -0,0 +1,24 @@ + + + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index efa2af5c4..c3a915750 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -67,6 +67,7 @@ import Cellsynt from "./Cellsynt.vue"; import WPush from "./WPush.vue"; import SIGNL4 from "./SIGNL4.vue"; import SendGrid from "./SendGrid.vue"; +import CeredSMS from "./CeredSMS.vue"; /** * Manage all notification form. @@ -142,6 +143,7 @@ const NotificationFormList = { "Cellsynt": Cellsynt, "WPush": WPush, "SendGrid": SendGrid, + "ceredsms": CeredSMS, }; export default NotificationFormList;