diff --git a/server/notification-providers/clicksendsms.js b/server/notification-providers/clicksendsms.js new file mode 100644 index 000000000..74e2f4c59 --- /dev/null +++ b/server/notification-providers/clicksendsms.js @@ -0,0 +1,42 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); + +class ClickSendSMS extends NotificationProvider { + + name = "clicksendsms"; + + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + let okMsg = "Sent Successfully."; + try { + console.log({ notification }); + let config = { + headers: { + "Content-Type": "application/json", + "Authorization": "Basic " + Buffer.from(notification.clicksendsmsLogin + ":" + notification.clicksendsmsPassword).toString('base64'), + "Accept": "text/json", + } + }; + let data = { + messages: [ + { + "body": msg.replace(/[^\x00-\x7F]/g, ""), + "to": notification.clicksendsmsToNumber, + "source": "uptime-kuma", + "from": notification.clicksendsmsSenderName, + } + ] + }; + let resp = await axios.post("https://rest.clicksend.com/v3/sms/send", data, config); + if (resp.data.data.messages[0].status !== "SUCCESS") { + let error = "Something gone wrong. Api returned " + resp.data.data.messages[0].status + "."; + this.throwGeneralAxiosError(error); + } + + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = ClickSendSMS; diff --git a/server/notification.js b/server/notification.js index 57453c4a8..18c823b2b 100644 --- a/server/notification.js +++ b/server/notification.js @@ -8,6 +8,7 @@ const Mattermost = require("./notification-providers/mattermost"); const Matrix = require("./notification-providers/matrix"); const Octopush = require("./notification-providers/octopush"); const PromoSMS = require("./notification-providers/promosms"); +const ClickSendSMS = require("./notification-providers/clicksendsms"); const Pushbullet = require("./notification-providers/pushbullet"); const Pushover = require("./notification-providers/pushover"); const Pushy = require("./notification-providers/pushy"); @@ -46,6 +47,7 @@ class Notification { new Matrix(), new Octopush(), new PromoSMS(), + new ClickSendSMS(), new Pushbullet(), new Pushover(), new Pushy(), diff --git a/src/components/notifications/ClickSendSMS.vue b/src/components/notifications/ClickSendSMS.vue new file mode 100644 index 000000000..2aed4184b --- /dev/null +++ b/src/components/notifications/ClickSendSMS.vue @@ -0,0 +1,38 @@ + + + API Username + + {{ $t("apiCredentials") }} + here + + + API Key + + + + + {{ $t("checkPrice", [$t("clicksendsms")]) }} + https://clicksend.com/us/pricing + + + + Recipient Number + + + + From Name/Number - + More Info + + + Leave blank to use a shared sender number. + + + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 2d8c9c09e..4b51569a2 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -11,6 +11,7 @@ import Pushover from "./Pushover.vue"; import Pushy from "./Pushy.vue"; import Octopush from "./Octopush.vue"; import PromoSMS from "./PromoSMS.vue"; +import ClickSendSMS from "./ClickSendSMS.vue"; import LunaSea from "./LunaSea.vue"; import Feishu from "./Feishu.vue"; import Apprise from "./Apprise.vue"; @@ -41,6 +42,7 @@ const NotificationFormList = { "pushy": Pushy, "octopush": Octopush, "promosms": PromoSMS, + "clicksendsms": ClickSendSMS, "lunasea": LunaSea, "Feishu": Feishu, "AliyunSMS": AliyunSMS, diff --git a/src/languages/en.js b/src/languages/en.js index 08c8b4a9f..58207d4dc 100644 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -240,6 +240,7 @@ export default { pushy: "Pushy", octopush: "Octopush", promosms: "PromoSMS", + clicksendsms: "ClickSend SMS", lunasea: "LunaSea", apprise: "Apprise (Support 50+ Notification services)", pushbullet: "Pushbullet", @@ -256,6 +257,7 @@ export default { octopushTypePremium: "Premium (Fast - recommended for alerting)", octopushTypeLowCost: "Low Cost (Slow - sometimes blocked by operator)", checkPrice: "Check {0} prices:", + apiCredentials: "API credentials", octopushLegacyHint: "Do you use the legacy version of Octopush (2011-2020) or the new version?", "Check octopush prices": "Check octopush prices {0}.", octopushPhoneNumber: "Phone number (intl format, eg : +33612345678) ",