diff --git a/server/notification-providers/serwersms.js b/server/notification-providers/serwersms.js index f7c8644af..5987153d5 100644 --- a/server/notification-providers/serwersms.js +++ b/server/notification-providers/serwersms.js @@ -17,14 +17,24 @@ class SerwerSMS extends NotificationProvider { "Content-Type": "application/json", } }; + let data = { "username": notification.serwersmsUsername, "password": notification.serwersmsPassword, - "phone": notification.serwersmsPhoneNumber, - "text": msg.replace(/[^\x00-\x7F]/g, ""), + "text": msg.replace(/[^\x00-\x7F]/g, ""), // SerwerSMS may not support special characters without UTF-8 encoding "sender": notification.serwersmsSenderName, }; + // **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 { + // 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); if (!resp.data.success) { @@ -32,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"); } } diff --git a/src/components/notifications/SerwerSMS.vue b/src/components/notifications/SerwerSMS.vue index 32a0ff7a8..7a156926e 100644 --- a/src/components/notifications/SerwerSMS.vue +++ b/src/components/notifications/SerwerSMS.vue @@ -3,14 +3,34 @@ +
+
- - +
+
+ + +
+ +
+ + +
+ +
+ + +
{{ $t("serwersmsGroupIdHelp") }}
+
{{ $t("serwersmsPhoneHelp") }}
+
+
diff --git a/src/lang/en.json b/src/lang/en.json index b6449371b..306354b4f 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -756,10 +756,14 @@ "alertaApiKey": "API Key", "alertaAlertState": "Alert State", "alertaRecoverState": "Recover State", - "serwersmsAPIUser": "API Username (incl. webapi_ prefix)", - "serwersmsAPIPassword": "API Password", + "serwersmsAPIUser": "API username (including the webapi_ prefix)", + "serwersmsAPIPassword": "API password", "serwersmsPhoneNumber": "Phone number", - "serwersmsSenderName": "SMS Sender Name (registered via customer portal)", + "serwersmsSenderName": "SMS sender name (registered via the client portal)", + "serwersmsGroupId": "Group ID", + "serwersmsGroupIdHelp": "Enter the GROUP ID (group_id from the SerwerSMS panel)", + "serwersmsDestinationType": "Recipient type", + "serwersmsPhoneHelp": "Enter the phone number, e.g., +48123456789.", "smseagleTo": "Phone number(s)", "smseagleGroup": "Phonebook group name(s)", "smseagleContact": "Phonebook contact name(s)",