mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-07-18 23:34:04 +02:00
Update serwersms.js
This commit is contained in:
parent
6a34cecc93
commit
c658beeddd
1 changed files with 9 additions and 9 deletions
|
@ -21,17 +21,18 @@ class SerwerSMS extends NotificationProvider {
|
|||
let data = {
|
||||
"username": notification.serwersmsUsername,
|
||||
"password": notification.serwersmsPassword,
|
||||
"text": msg.replace(/[^\x00-\x7F]/g, ""), // SerwerSMS może nie obsługiwać znaków specjalnych bez utf
|
||||
"text": msg.replace(/[^\x00-\x7F]/g, ""), // SerwerSMS may not support special characters without UTF-8 encoding
|
||||
"sender": notification.serwersmsSenderName,
|
||||
};
|
||||
|
||||
// Obsługa numeru telefonu lub grupy
|
||||
if (notification.serwersmsGroupId) {
|
||||
data.group_id = notification.serwersmsGroupId;
|
||||
} else if (notification.serwersmsPhoneNumber) {
|
||||
data.phone = notification.serwersmsPhoneNumber;
|
||||
// **CHANGED:** Now uses notification.destinationType and notification.destinationValue directly
|
||||
if (notification.destinationType === "group") {
|
||||
data.group_id = notification.destinationValue;
|
||||
} else if (notification.destinationType === "phone") {
|
||||
data.phone = notification.destinationValue;
|
||||
} else {
|
||||
throw new Error("SerwerSMS: Either phone number or group_id must be provided.");
|
||||
// Throws an error if recipient type is not defined or invalid
|
||||
throw new Error("SerwerSMS: Recipient type (phone number or group ID) must be defined.");
|
||||
}
|
||||
|
||||
let resp = await axios.post(url, data, config);
|
||||
|
@ -41,8 +42,7 @@ class SerwerSMS extends NotificationProvider {
|
|||
let error = `SerwerSMS.pl API returned error code ${resp.data.error.code} (${resp.data.error.type}) with error message: ${resp.data.error.message}`;
|
||||
this.throwGeneralAxiosError(error);
|
||||
} else {
|
||||
let error = "SerwerSMS.pl API returned an unexpected response";
|
||||
this.throwGeneralAxiosError(error);
|
||||
this.throwGeneralAxiosError("SerwerSMS.pl API returned an unexpected response");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue