From c658beeddde6d9544cf2d4a12854dcd7b7457782 Mon Sep 17 00:00:00 2001 From: miesiu <44501255+miesiu@users.noreply.github.com> Date: Fri, 18 Jul 2025 12:54:52 +0200 Subject: [PATCH] Update serwersms.js --- server/notification-providers/serwersms.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/server/notification-providers/serwersms.js b/server/notification-providers/serwersms.js index 8d172536e..5987153d5 100644 --- a/server/notification-providers/serwersms.js +++ b/server/notification-providers/serwersms.js @@ -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"); } }