From ad707f63444f1eb7c8ccf12799038d583835014b Mon Sep 17 00:00:00 2001 From: AxeKam333 Date: Thu, 24 Apr 2025 11:49:08 +0200 Subject: [PATCH] Apply suggestions from code review 2 --- server/notification-providers/smseagle.js | 46 ++++++-------------- src/components/notifications/SMSEagle.vue | 52 +++++++++++++---------- src/lang/en.json | 8 ++-- 3 files changed, 47 insertions(+), 59 deletions(-) diff --git a/server/notification-providers/smseagle.js b/server/notification-providers/smseagle.js index c72d0981f..35854473c 100644 --- a/server/notification-providers/smseagle.js +++ b/server/notification-providers/smseagle.js @@ -50,9 +50,9 @@ class SMSEagle extends NotificationProvider { url.searchParams.append("access_token", notification.smseagleToken); url.searchParams.append(recipientType, notification.smseagleRecipient); - if ("smseagle-sms" === notification.smseagleRecipientType) { + if (notification.smseagleRecipientType == null || notification.smseagleRecipientType === "smseagle-sms") { url.searchParams.append("unicode", (notification.smseagleEncoding) ? "1" : "0"); - url.searchParams.append("highpriority", (notification.smseaglePriority) ? notification.smseaglePriority : "0"); + url.searchParams.append("highpriority", notification.smseaglePriority ?? "0"); } else { url.searchParams.append("duration", duration); } @@ -80,7 +80,7 @@ class SMSEagle extends NotificationProvider { }; let encoding = (notification.smseagleEncoding) ? "unicode" : "standard"; - let priority = (notification.smseaglePriority) ? notification.smseaglePriority : 0; + let priority = (notification.smseaglePriority) ?? 0; let postData = { text: msg, @@ -88,43 +88,21 @@ class SMSEagle extends NotificationProvider { priority: priority }; - let to = notification.smseagleRecipientTo; - let contacts = notification.smseagleRecipientContact; - let groups = notification.smseagleRecipientGroup; - - if (contacts) { - contacts = contacts.split(","); - contacts = contacts.map(e => { - return Number(e); - }); - postData["contacts"] = contacts; + if (notification.smseagleRecipientContact) { + postData["contacts"] = notification.smseagleRecipientContact.split(",").map(Number); } - - if (groups) { - groups = groups.split(","); - groups = groups.map(e => { - return Number(e); - }); - postData["groups"] = groups; + if (notification.smseagleRecipientGroup) { + postData["groups"] = notification.smseagleRecipientGroup.split(",").map(Number); } - - if (to) { - to = to.split(","); - postData["to"] = to; + if (notification.smseagleRecipientTo) { + postData["to"] = notification.smseagleRecipientTo.split(","); } let endpoint = "/messages/sms"; if (notification.smseagleMsgType !== "smseagle-sms") { - let duration; - if (notification.smseagleDuration) { - duration = notification.smseagleDuration; - } else { - duration = 10; - } - - postData["duration"] = duration; + postData["duration"] = notification.smseagleDuration ?? 10; if (notification.smseagleMsgType === "smseagle-ring") { endpoint = "/calls/ring"; @@ -132,7 +110,7 @@ class SMSEagle extends NotificationProvider { endpoint = "/calls/tts"; } else if (notification.smseagleMsgType === "smseagle-tts-advanced") { endpoint = "/calls/tts_advanced"; - postData["voice_id"] = notification.smseagleTtsModel ? notification.smseagleTtsModel : "1"; + postData["voice_id"] = notification.smseagleTtsModel ?? 1; } } @@ -149,7 +127,7 @@ class SMSEagle extends NotificationProvider { } if (unqueuedCount) { - return `Sent ${countQueued}/${resp.data.length} Messages Successfully.`; + return `Sent ${queuedCount}/${resp.data.length} Messages Successfully.`; } return okMsg; diff --git a/src/components/notifications/SMSEagle.vue b/src/components/notifications/SMSEagle.vue index c59abe3a6..16277a6ef 100644 --- a/src/components/notifications/SMSEagle.vue +++ b/src/components/notifications/SMSEagle.vue @@ -3,7 +3,7 @@
@@ -16,6 +16,9 @@ + + https://www.smseagle.eu/api/ +
@@ -24,6 +27,7 @@ id="smseagle-recipient-type" v-model="$parent.notification.smseagleRecipientType" class="form-select" > + @@ -33,9 +37,12 @@
-
+
- +
- + + + +
- - + + +
- - + + +
- - -
-
- - + +
- - + +
- - @@ -103,12 +111,12 @@
- - + +
- - + +
diff --git a/src/lang/en.json b/src/lang/en.json index 4375032d6..759678015 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -763,18 +763,20 @@ "smseagleRecipient": "Recipient(s) (multiple must be separated with comma)", "smseagleToken": "API Access token", "smseagleUrl": "Your SMSEagle device URL", - "smseagleEncoding": "Send as Unicode", - "smseaglePriority": "Message priority (0-9, default = 0)", + "smseagleEncoding": "Send as Unicode (default=GSM-7)", + "smseaglePriority": "Message priority (0-9, highest priority = 9)", "smseagleMsgType": "Message type", "smseagleMsgSms": "Sms message (default)", "smseagleMsgRing": "Ring call", "smseagleMsgTts": "Text-to-speech call", "smseagleMsgTtsAdvanced": "Text-to-speech Advanced call", - "smseagleDuration": "Duration (default=10)", + "smseagleDuration": "Duration (in seconds)", "smseagleTtsModel": "Text-to-speech model ID", "smseagleApiType": "API version", "smseagleApiv1": "APIv1 (for existing projects and backward compatibility)", "smseagleApiv2": "APIv2 (recommended for new integrations)", + "smseagleDocs": "Check documentation or APIv2 availability: {0}", + "smseagleComma": "Multiple must be separated with comma", "smspartnerApiurl": "You can find your API key in your dashboard at {0}", "smspartnerPhoneNumber": "Phone number(s)", "smspartnerPhoneNumberHelptext": "The number must be in the international format {0}, {1}. Multiple numbers must be separated by {2}",