From 6164cff8e7978a13bc7d169a1c3ea5b768ebf5f2 Mon Sep 17 00:00:00 2001 From: AxeKam333 Date: Mon, 7 Apr 2025 14:38:04 +0200 Subject: [PATCH] Add ESLint formatting --- server/notification-providers/smseagle.js | 63 ++++++++++++----------- src/components/notifications/SMSEagle.vue | 54 +++++++++++-------- src/lang/pl.json | 6 +-- 3 files changed, 68 insertions(+), 55 deletions(-) diff --git a/server/notification-providers/smseagle.js b/server/notification-providers/smseagle.js index d2ebdcafe..9db7918b4 100644 --- a/server/notification-providers/smseagle.js +++ b/server/notification-providers/smseagle.js @@ -11,7 +11,7 @@ class SMSEagle extends NotificationProvider { const okMsg = "Sent Successfully."; try { - if (notification.smseagleApiType === "smseagle-apiv1") { + if (notification.smseagleApiType === "smseagle-apiv1") { // according to https://www.smseagle.eu/apiv1/ let config = { headers: { "Content-Type": "application/x-www-form-urlencoded", @@ -20,7 +20,8 @@ class SMSEagle extends NotificationProvider { let sendMethod; let recipientType; - let duration, voice_id; + let duration; + let voiceId; if (notification.smseagleRecipientType === "smseagle-contact") { recipientType = "contactname"; @@ -31,38 +32,39 @@ class SMSEagle extends NotificationProvider { } else if (notification.smseagleRecipientType === "smseagle-to") { recipientType = "to"; sendMethod = "/send_sms"; - if (notification.smseagleMsgType != "smseagle-sms") { - if (notification.smseagleDuration) + if (notification.smseagleMsgType !== "smseagle-sms") { + if (notification.smseagleDuration) { duration = notification.smseagleDuration; - else + } else { duration = 10; + } - if (notification.smseagleMsgType == "smseagle-ring") { + if (notification.smseagleMsgType === "smseagle-ring") { sendMethod = "/ring_call"; - } else if (notification.smseagleMsgType == "smseagle-tts") { + } else if (notification.smseagleMsgType === "smseagle-tts") { sendMethod = "/tts_call"; - } else if (notification.smseagleMsgType == "smseagle-tts-advanced") { + } else if (notification.smseagleMsgType === "smseagle-tts-advanced") { sendMethod = "/tts_adv_call"; - voice_id = notification.smseagleTtsModel ? notification.smseagleTtsModel : 1; + voiceId = notification.smseagleTtsModel ? notification.smseagleTtsModel : 1; } } } const url = new URL(notification.smseagleUrl + "/http_api" + sendMethod); - url.searchParams.append('access_token', notification.smseagleToken); + url.searchParams.append("access_token", notification.smseagleToken); url.searchParams.append(recipientType, notification.smseagleRecipient); - if (!["smseagle-ring", "smseagle-tts", "smseagle-tts-advanced"].includes(notification.smseagleRecipientType)) { - url.searchParams.append('unicode', (notification.smseagleEncoding) ? "1" : "0"); - url.searchParams.append('highpriority', (notification.smseaglePriority) ? notification.smseaglePriority : "0"); + if (![ "smseagle-ring", "smseagle-tts", "smseagle-tts-advanced" ].includes(notification.smseagleRecipientType)) { + url.searchParams.append("access_token", (notification.smseagleEncoding) ? "1" : "0"); + url.searchParams.append("access_token", (notification.smseaglePriority) ? notification.smseaglePriority : "0"); } else { - url.searchParams.append('duration', duration); + url.searchParams.append("duration", duration); } - if (notification.smseagleRecipientType != "smseagle-ring") { - url.searchParams.append('message', msg); + if (notification.smseagleRecipientType !== "smseagle-ring") { + url.searchParams.append("message", msg); } - if (voice_id) { - url.searchParams.append('voice_id', voice_id); + if (voiceId) { + url.searchParams.append("voice_id", voiceId); } let resp = await axios.get(url.toString(), config); @@ -73,7 +75,7 @@ class SMSEagle extends NotificationProvider { } return okMsg; - } else if (notification.smseagleApiType === "smseagle-apiv2") { + } else if (notification.smseagleApiType === "smseagle-apiv2") { // according to https://www.smseagle.eu/docs/apiv2/ let config = { headers: { "access-token": notification.smseagleToken, @@ -97,7 +99,7 @@ class SMSEagle extends NotificationProvider { if (contacts) { contacts = contacts.split(","); contacts = contacts.map(e => { - return Number(e) + return Number(e); }); postData["contacts"] = contacts; } @@ -105,7 +107,7 @@ class SMSEagle extends NotificationProvider { if (groups) { groups = groups.split(","); groups = groups.map(e => { - return Number(e) + return Number(e); }); postData["groups"] = groups; } @@ -117,21 +119,22 @@ class SMSEagle extends NotificationProvider { let endpoint = "/messages/sms"; - if (notification.smseagleMsgType != "smseagle-sms") { + if (notification.smseagleMsgType !== "smseagle-sms") { let duration; - if (notification.smseagleDuration) - duration = notification.smseagleDuration - else + if (notification.smseagleDuration) { + duration = notification.smseagleDuration; + } else { duration = 10; + } postData["duration"] = duration; - if (notification.smseagleMsgType == "smseagle-ring") { + if (notification.smseagleMsgType === "smseagle-ring") { endpoint = "/calls/ring"; - } else if (notification.smseagleMsgType == "smseagle-tts") { + } else if (notification.smseagleMsgType === "smseagle-tts") { endpoint = "/calls/tts"; - } else if (notification.smseagleMsgType == "smseagle-tts-advanced") { + } else if (notification.smseagleMsgType === "smseagle-tts-advanced") { endpoint = "/calls/tts_advanced"; postData["voice_id"] = notification.smseagleTtsModel ? notification.smseagleTtsModel : "1"; } @@ -140,9 +143,9 @@ class SMSEagle extends NotificationProvider { let resp = await axios.post(notification.smseagleUrl + "/api/v2" + endpoint, postData, config); let countAll = resp.data.length; - let countQueued = resp.data.filter(x => x.status == "queued").length; + let countQueued = resp.data.filter(x => x.status === "queued").length; - if (resp.status !== 200 || countQueued == 0) { + if (resp.status !== 200 || countQueued === 0) { let error = ""; if (resp.data.length > 0) { error = `SMSEagle API returned error: ${JSON.stringify(resp.data)}`; diff --git a/src/components/notifications/SMSEagle.vue b/src/components/notifications/SMSEagle.vue index ff7834f6e..c59abe3a6 100644 --- a/src/components/notifications/SMSEagle.vue +++ b/src/components/notifications/SMSEagle.vue @@ -1,8 +1,10 @@ @@ -112,13 +122,13 @@ export default { }, mounted() { if (!this.$parent.notification.smseagleApiType) { - this.$parent.notification.smseagleApiType = 'smseagle-apiv1'; + this.$parent.notification.smseagleApiType = "smseagle-apiv1"; } if (!this.$parent.notification.smseagleMsgType) { - this.$parent.notification.smseagleMsgType = 'smseagle-sms'; + this.$parent.notification.smseagleMsgType = "smseagle-sms"; } if (!this.$parent.notification.smseagleRecipientType) { - this.$parent.notification.smseagleRecipientType = 'smseagle-to'; + this.$parent.notification.smseagleRecipientType = "smseagle-to"; } } }; diff --git a/src/lang/pl.json b/src/lang/pl.json index 180ecf61e..739afeecd 100644 --- a/src/lang/pl.json +++ b/src/lang/pl.json @@ -363,8 +363,8 @@ "serwersmsSenderName": "Nazwa nadawcy (zatwierdzona w panelu klienta)", "smseagle": "SMSEagle", "smseagleTo": "Numer/y telefonu", - "smseagleGroup": "Grupa/y z Książki adresowej", - "smseagleContact": "Kontakt/y z Książki adresowej", + "smseagleGroup": "Grupa/y z Książki adresowej - nazwa", + "smseagleContact": "Kontakt/y z Książki adresowej - nazwa", "smseagleGroupV2": "Grupa/y z Książki adresowej - ID", "smseagleContactV2": "Kontakt/y z Książki adresowej - ID", "smseagleRecipientType": "Typ odbiorcy", @@ -380,7 +380,7 @@ "smseagleMsgTtsAdvanced": "Połączenie text-to-speech (zaawansowane)", "smseagleDuration": "Czas trwania (domyślnie=10)", "smseagleTtsModel": "ID modelu głosowego TTS", - "smseagleApiType": "wersja API", + "smseagleApiType": "Wersja API", "smseagleApiv1": "APIv1 (dla istniejących projektów)", "smseagleApiv2": "APIv2 (zalecane dla nowych integracji)", "stackfield": "Stackfield",