From a7b2624c2d96b5ad390618ae6ad1196a8daec147 Mon Sep 17 00:00:00 2001 From: Amirparsa Baghdadi <76398455+amirparsadd@users.noreply.github.com> Date: Tue, 11 Nov 2025 15:03:52 +0330 Subject: [PATCH] SMSIR Notification Provider Support (#6334) Co-authored-by: Frank Elsinga --- server/notification-providers/smsir.js | 52 ++++++++++++++++++++++++++ server/notification.js | 2 + src/components/NotificationDialog.vue | 1 + src/components/notifications/SMSIR.vue | 31 +++++++++++++++ src/components/notifications/index.js | 2 + src/lang/en.json | 4 +- 6 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 server/notification-providers/smsir.js create mode 100644 src/components/notifications/SMSIR.vue diff --git a/server/notification-providers/smsir.js b/server/notification-providers/smsir.js new file mode 100644 index 000000000..159eccb2c --- /dev/null +++ b/server/notification-providers/smsir.js @@ -0,0 +1,52 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); + +class SMSIR extends NotificationProvider { + name = "smsir"; + + /** + * @inheritdoc + */ + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + const okMsg = "Sent Successfully."; + const url = "https://api.sms.ir/v1/send/verify"; + + try { + let config = { + headers: { + "Content-Type": "application/json", + "Accept": "application/json", + "X-API-Key": notification.smsirApiKey + } + }; + config = this.getAxiosConfigWithProxy(config); + + let formattedMobile = notification.smsirNumber; + if (formattedMobile.length === 11 && formattedMobile.startsWith("09") && String(parseInt(formattedMobile)) === formattedMobile.substring(1)) { + // 09xxxxxxxxx Format + formattedMobile = formattedMobile.substring(1); + } + + await axios.post( + url, + { + mobile: formattedMobile, + templateId: parseInt(notification.smsirTemplate), + parameters: [ + { + name: "uptkumaalert", + value: msg + } + ] + }, + config + ); + + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = SMSIR; diff --git a/server/notification.js b/server/notification.js index 31028e3dd..6b182ffbb 100644 --- a/server/notification.js +++ b/server/notification.js @@ -81,6 +81,7 @@ const Brevo = require("./notification-providers/brevo"); const YZJ = require("./notification-providers/yzj"); const SMSPlanet = require("./notification-providers/sms-planet"); const SpugPush = require("./notification-providers/spugpush"); +const SMSIR = require("./notification-providers/smsir"); const { commandExists } = require("./util-server"); class Notification { @@ -179,6 +180,7 @@ class Notification { new SMSPlanet(), new SpugPush(), new Notifery(), + new SMSIR(), ]; for (let item of list) { if (!item.name) { diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index ad882fcca..702d0be19 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -192,6 +192,7 @@ export default { "PushPlus": "PushPlus (推送加)", "SpugPush": "SpugPush(Spug推送助手)", "smsc": "SMSC", + "smsir": "SMS.IR", "WPush": "WPush(wpush.cn)", "YZJ": "YZJ (云之家自定义机器人)", "SMSPlanet": "SMSPlanet.pl" diff --git a/src/components/notifications/SMSIR.vue b/src/components/notifications/SMSIR.vue new file mode 100644 index 000000000..e5e0e6407 --- /dev/null +++ b/src/components/notifications/SMSIR.vue @@ -0,0 +1,31 @@ + + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index bf74b178e..c46690a0d 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -79,6 +79,7 @@ import SendGrid from "./SendGrid.vue"; import Brevo from "./Brevo.vue"; import YZJ from "./YZJ.vue"; import SMSPlanet from "./SMSPlanet.vue"; +import SMSIR from "./SMSIR.vue"; /** * Manage all notification form. @@ -95,6 +96,7 @@ const NotificationFormList = { "clicksendsms": ClickSendSMS, "CallMeBot": CallMeBot, "smsc": SMSC, + "smsir": SMSIR, "DingDing": DingDing, "discord": Discord, "Elks": Elks, diff --git a/src/lang/en.json b/src/lang/en.json index b559d8ab3..e1c2d8ab2 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -1184,5 +1184,7 @@ "Send DOWN silently": "Send DOWN silently", "Installing a Nextcloud Talk bot requires administrative access to the server.": "Installing a Nextcloud Talk bot requires administrative access to the server.", "Number of retry attempts if webhook fails": "Number of retry attempts (every 60-180 seconds) if the webhook fails.", - "Maximum Retries": "Maximum Retries" + "Maximum Retries": "Maximum Retries", + "Template ID": "Template ID", + "wayToGetClickSMSIRTemplateID": "Your template must contain an {uptkumaalert} field. You can create a new template {here}." }