mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-04-22 00:09:22 -04:00
Add ESLint formatting
This commit is contained in:
parent
fdec75abe9
commit
6164cff8e7
@ -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)}`;
|
||||
|
@ -1,8 +1,10 @@
|
||||
<template>
|
||||
<div class="mb-3">
|
||||
<label for="smseagle-url" class="form-label">{{ $t("smseagleUrl") }}</label>
|
||||
<input id="smseagle-url" v-model="$parent.notification.smseagleUrl" type="text" minlength="7"
|
||||
class="form-control" placeholder="http://127.0.0.1" required>
|
||||
<input
|
||||
id="smseagle-url" v-model="$parent.notification.smseagleUrl" type="text" minlength="7"
|
||||
class="form-control" placeholder="http://127.0.0.1"
|
||||
>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="smseagle-token" class="form-label">{{ $t("smseagleToken") }}</label>
|
||||
@ -18,8 +20,10 @@
|
||||
<div v-if="$parent.notification.smseagleApiType === 'smseagle-apiv1'" class="mb-3">
|
||||
<div class="mb-3">
|
||||
<label for="smseagle-recipient-type" class="form-label">{{ $t("smseagleRecipientType") }}</label>
|
||||
<select id="smseagle-recipient-type" v-model="$parent.notification.smseagleRecipientType"
|
||||
class="form-select">
|
||||
<select
|
||||
id="smseagle-recipient-type" v-model="$parent.notification.smseagleRecipientType"
|
||||
class="form-select"
|
||||
>
|
||||
<option value="smseagle-to" selected>{{ $t("smseagleTo") }}</option>
|
||||
<option value="smseagle-group">{{ $t("smseagleGroup") }}</option>
|
||||
<option value="smseagle-contact">{{ $t("smseagleContact") }}</option>
|
||||
@ -33,28 +37,34 @@
|
||||
<label for="smseagle-priority" class="form-label">{{ $t("smseaglePriority") }}</label>
|
||||
<input id="smseagle-priority" v-model="$parent.notification.smseaglePriority" type="number" class="form-control" min="0" max="9" step="1" placeholder="0">
|
||||
</div>
|
||||
<div v-if="$parent.notification.smseagleMsgType === 'smseagle-sms'
|
||||
|| $parent.notification.smseagleRecipientType !== 'smseagle-to'" class="mb-3 form-check form-switch">
|
||||
<div
|
||||
v-if="$parent.notification.smseagleMsgType === 'smseagle-sms'
|
||||
|| $parent.notification.smseagleRecipientType !== 'smseagle-to'" class="mb-3 form-check form-switch"
|
||||
>
|
||||
<label for="smseagle-encoding" class="form-label">{{ $t("smseagleEncoding") }}</label>
|
||||
<input id="smseagle-encoding" v-model="$parent.notification.smseagleEncoding" type="checkbox" class="form-check-input">
|
||||
</div>
|
||||
<div v-if="$parent.notification.smseagleRecipientType === 'smseagle-to'" class="mb-3">
|
||||
<label for="smseagle-msg-type" class="form-label">{{ $t("smseagleMsgType") }} </label>
|
||||
<select id="smseagle-msg-type" v-model="$parent.notification.smseagleMsgType" class="form-select">
|
||||
<option value="smseagle-sms" selected>{{ $t("smseagleMsgSms") }} </option>
|
||||
<option value="smseagle-ring">{{ $t("smseagleMsgRing") }} </option>
|
||||
<option value="smseagle-tts">{{ $t("smseagleMsgTts") }} </option>
|
||||
<option value="smseagle-tts-advanced">{{ $t("smseagleMsgTtsAdvanced") }} </option>
|
||||
</select>
|
||||
<div v-if="$parent.notification.smseagleMsgType === 'smseagle-ring'
|
||||
|| $parent.notification.smseagleMsgType === 'smseagle-tts'
|
||||
|| $parent.notification.smseagleMsgType === 'smseagle-tts-advanced'" class="mb-3">
|
||||
<div class="mb-3">
|
||||
<label for="smseagle-msg-type" class="form-label">{{ $t("smseagleMsgType") }} </label>
|
||||
<select id="smseagle-msg-type" v-model="$parent.notification.smseagleMsgType" class="form-select">
|
||||
<option value="smseagle-sms" selected>{{ $t("smseagleMsgSms") }} </option>
|
||||
<option value="smseagle-ring">{{ $t("smseagleMsgRing") }} </option>
|
||||
<option value="smseagle-tts">{{ $t("smseagleMsgTts") }} </option>
|
||||
<option value="smseagle-tts-advanced">{{ $t("smseagleMsgTtsAdvanced") }} </option>
|
||||
</select>
|
||||
</div>
|
||||
<div
|
||||
v-if="$parent.notification.smseagleMsgType === 'smseagle-ring'
|
||||
|| $parent.notification.smseagleMsgType === 'smseagle-tts'
|
||||
|| $parent.notification.smseagleMsgType === 'smseagle-tts-advanced'" class="mb-3"
|
||||
>
|
||||
<label for="smseagle-duration" class="form-label">{{ $t("smseagleDuration") }}</label>
|
||||
<input id="smseagle-duration" v-model="$parent.notification.smseagleDuration" type="number" class="form-control" min="0" max="30" step="1" placeholder="10">
|
||||
</div>
|
||||
<div v-if="$parent.notification.smseagleMsgType === 'smseagle-tts-advanced'" class="mb-3">
|
||||
<label for="smseagle-tts-model" class="form-label">{{ $t("smseagleTtsModel") }} </label>
|
||||
<input id="smseagle-tts-model" v-model="$parent.notification.smseagleTtsModel" type="number" class="form-control" placeholder="1" required>
|
||||
<input id="smseagle-tts-model" v-model="$parent.notification.smseagleTtsModel" type="number" class="form-control" placeholder="1" required>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -92,13 +102,13 @@
|
||||
<option value="smseagle-tts-advanced">{{ $t("smseagleMsgTtsAdvanced") }} </option>
|
||||
</select>
|
||||
</div>
|
||||
<div v-if="$parent.notification.smseagleMsgType && $parent.notification.smseagleMsgType !== 'smseagle-sms'" class="mb-3">
|
||||
<div v-if="$parent.notification.smseagleMsgType && $parent.notification.smseagleMsgType !== 'smseagle-sms'" class="mb-3">
|
||||
<label for="smseagle-duration" class="form-label">{{ $t("smseagleDuration") }}</label>
|
||||
<input id="smseagle-duration" v-model="$parent.notification.smseagleDuration" type="number" class="form-control" min="0" max="30" step="1" placeholder="10">
|
||||
</div>
|
||||
<div v-if="$parent.notification.smseagleMsgType === 'smseagle-tts-advanced'" class="mb-3">
|
||||
<label for="smseagle-tts-model" class="form-label">{{ $t("smseagleTtsModel") }} </label>
|
||||
<input id="smseagle-tts-model" v-model="$parent.notification.smseagleTtsModel" type="number" class="form-control" placeholder="1" required>
|
||||
<input id="smseagle-tts-model" v-model="$parent.notification.smseagleTtsModel" type="number" class="form-control" placeholder="1" required>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -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";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user