mirror of
https://github.com/louislam/uptime-kuma.git
synced 2026-01-06 18:55:38 -05:00
feat: Multi number notifications for SMSIR (#6346)
This commit is contained in:
parent
a7b2624c2d
commit
319edddae5
3 changed files with 33 additions and 21 deletions
|
|
@ -21,26 +21,37 @@ class SMSIR extends NotificationProvider {
|
|||
};
|
||||
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);
|
||||
}
|
||||
const formattedMobiles = notification.smsirNumber
|
||||
.split(",")
|
||||
.map(mobile => {
|
||||
if (mobile.length === 11 && mobile.startsWith("09") && String(parseInt(mobile)) === mobile.substring(1)) {
|
||||
// 09xxxxxxxxx Format
|
||||
return mobile.substring(1);
|
||||
}
|
||||
|
||||
await axios.post(
|
||||
url,
|
||||
{
|
||||
mobile: formattedMobile,
|
||||
templateId: parseInt(notification.smsirTemplate),
|
||||
parameters: [
|
||||
return mobile;
|
||||
});
|
||||
|
||||
// Run multiple network requests at once
|
||||
const requestPromises = formattedMobiles
|
||||
.map(mobile => {
|
||||
axios.post(
|
||||
url,
|
||||
{
|
||||
name: "uptkumaalert",
|
||||
value: msg
|
||||
}
|
||||
]
|
||||
},
|
||||
config
|
||||
);
|
||||
mobile: mobile,
|
||||
templateId: parseInt(notification.smsirTemplate),
|
||||
parameters: [
|
||||
{
|
||||
name: "uptkumaalert",
|
||||
value: msg
|
||||
}
|
||||
]
|
||||
},
|
||||
config
|
||||
);
|
||||
});
|
||||
|
||||
await Promise.all(requestPromises);
|
||||
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
<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>
|
||||
<label for="smsir-number" class="form-label">{{ $t("Recipient Numbers") }}</label>
|
||||
<input id="smsir-number" v-model="$parent.notification.smsirNumber" placeholder="9123456789,09987654321" type="text" minlength="10" class="form-control" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="smsir-template" class="form-label">{{ $t("Template ID") }}</label>
|
||||
|
|
|
|||
|
|
@ -1186,5 +1186,6 @@
|
|||
"Number of retry attempts if webhook fails": "Number of retry attempts (every 60-180 seconds) if the webhook fails.",
|
||||
"Maximum Retries": "Maximum Retries",
|
||||
"Template ID": "Template ID",
|
||||
"wayToGetClickSMSIRTemplateID": "Your template must contain an {uptkumaalert} field. You can create a new template {here}."
|
||||
"wayToGetClickSMSIRTemplateID": "Your template must contain an {uptkumaalert} field. You can create a new template {here}.",
|
||||
"Recipient Numbers": "Recipient Numbers"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue