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