diff --git a/server/notification-providers/smsc.js b/server/notification-providers/smsc.js new file mode 100644 index 000000000..251bc4554 --- /dev/null +++ b/server/notification-providers/smsc.js @@ -0,0 +1,42 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); + +class SMSC extends NotificationProvider { + name = "smsc"; + + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + let okMsg = "Sent Successfully."; + try { + let config = { + headers: { + "Content-Type": "application/json", + "Accept": "text/json", + } + }; + + let getArray = [ + "fmt=3", + "translit=" + notification.smscTranslit, + "login=" + notification.smscLogin, + "psw=" + notification.smscPassword, + "phones=" + notification.smscToNumber, + "mes=" + encodeURIComponent(msg.replace(/[^\x00-\x7F]/g, "")), + ]; + if (notification.smscSenderName !== "") { + getArray.push("sender=" + notification.smscSenderName); + } + + let resp = await axios.get("https://smsc.kz/sys/send.php?" + getArray.join("&"), config); + if (resp.data.id === undefined) { + let error = `Something gone wrong. Api returned code ${resp.data.error_code}: ${resp.data.error}`; + this.throwGeneralAxiosError(error); + } + + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = SMSC; diff --git a/server/notification.js b/server/notification.js index 9bfa371d9..ea5c8ee07 100644 --- a/server/notification.js +++ b/server/notification.js @@ -6,6 +6,7 @@ const AliyunSms = require("./notification-providers/aliyun-sms"); const Apprise = require("./notification-providers/apprise"); const Bark = require("./notification-providers/bark"); const ClickSendSMS = require("./notification-providers/clicksendsms"); +const SMSC = require("./notification-providers/smsc"); const DingDing = require("./notification-providers/dingding"); const Discord = require("./notification-providers/discord"); const Feishu = require("./notification-providers/feishu"); @@ -68,6 +69,7 @@ class Notification { new Apprise(), new Bark(), new ClickSendSMS(), + new SMSC(), new DingDing(), new Discord(), new Feishu(), diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index 856d6f537..f977225f9 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -164,6 +164,7 @@ export default { "SMSManager": "SmsManager (smsmanager.cz)", "WeCom": "WeCom (企业微信群机器人)", "ServerChan": "ServerChan (Server酱)", + "smsc": "SMSC", }; // Sort by notification name diff --git a/src/components/notifications/SMSC.vue b/src/components/notifications/SMSC.vue new file mode 100644 index 000000000..36a0a8957 --- /dev/null +++ b/src/components/notifications/SMSC.vue @@ -0,0 +1,43 @@ + + + {{ $t("API Username") }} + + {{ $t("here") }} + + + {{ $t("API Key") }} + + + + + {{ $t("checkPrice", ['СМСЦ']) }} + https://smsc.kz/tariffs/ + + + + {{ $t("Recipient Number") }} + + + + {{ $t("From Name/Number") }} + + {{ $t("Leave blank to use a shared sender number.") }} + + + {{ $t("smscTranslit") }}* + + {{ $t("Default") }} + Translit + MpaHc/Ium + + + + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 7b5e6b6c7..673a84a98 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -4,6 +4,7 @@ import AliyunSMS from "./AliyunSms.vue"; import Apprise from "./Apprise.vue"; import Bark from "./Bark.vue"; import ClickSendSMS from "./ClickSendSMS.vue"; +import SMSC from "./SMSC.vue"; import DingDing from "./DingDing.vue"; import Discord from "./Discord.vue"; import Feishu from "./Feishu.vue"; @@ -61,6 +62,7 @@ const NotificationFormList = { "apprise": Apprise, "Bark": Bark, "clicksendsms": ClickSendSMS, + "smsc": SMSC, "DingDing": DingDing, "discord": Discord, "Feishu": Feishu,