1
0
mirror of https://github.com/louislam/uptime-kuma.git synced 2025-11-23 22:37:10 +02:00

SMSIR Notification Provider Support (#6334)

Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
Amirparsa Baghdadi
2025-11-11 15:03:52 +03:30
committed by GitHub
parent 2d8918a1b8
commit a7b2624c2d
6 changed files with 91 additions and 1 deletions

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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"

View File

@@ -0,0 +1,31 @@
<template>
<div class="mb-3">
<label for="smsir-key" class="form-label">{{ $t("API Key") }}</label>
<HiddenInput id="smsir-key" v-model="$parent.notification.smsirApiKey" :required="true" autocomplete="new-password"></HiddenInput>
</div>
<div class="mb-3">
<label for="smsir-number" class="form-label">{{ $t("Recipient Number") }}</label>
<input id="smsir-number" v-model="$parent.notification.smsirNumber" placeholder="9123456789" type="text" maxlength="11" minlength="10" class="form-control" required>
</div>
<div class="mb-3">
<label for="smsir-template" class="form-label">{{ $t("Template ID") }}</label>
<input id="smsir-template" v-model="$parent.notification.smsirTemplate" placeholder="12345" type="text" class="form-control" required>
<i18n-t tag="div" class="form-text" keypath="wayToGetClickSMSIRTemplateID">
<template #uptkumaalert>
<code>#uptkumaalert#</code>
</template>
<template #here>
<a href="https://app.sms.ir/fast-send/template" target="_blank">{{ $t("here") }}</a>
</template>
</i18n-t>
</div>
</template>
<script>
import HiddenInput from "../HiddenInput.vue";
export default {
components: {
HiddenInput,
},
};
</script>

View File

@@ -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,

View File

@@ -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}."
}