mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-06-06 21:12:34 +02:00
Apply suggestions from code review 2
This commit is contained in:
parent
cd22baab1d
commit
ad707f6344
3 changed files with 47 additions and 59 deletions
|
@ -50,9 +50,9 @@ class SMSEagle extends NotificationProvider {
|
||||||
|
|
||||||
url.searchParams.append("access_token", notification.smseagleToken);
|
url.searchParams.append("access_token", notification.smseagleToken);
|
||||||
url.searchParams.append(recipientType, notification.smseagleRecipient);
|
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("unicode", (notification.smseagleEncoding) ? "1" : "0");
|
||||||
url.searchParams.append("highpriority", (notification.smseaglePriority) ? notification.smseaglePriority : "0");
|
url.searchParams.append("highpriority", notification.smseaglePriority ?? "0");
|
||||||
} else {
|
} else {
|
||||||
url.searchParams.append("duration", duration);
|
url.searchParams.append("duration", duration);
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ class SMSEagle extends NotificationProvider {
|
||||||
};
|
};
|
||||||
|
|
||||||
let encoding = (notification.smseagleEncoding) ? "unicode" : "standard";
|
let encoding = (notification.smseagleEncoding) ? "unicode" : "standard";
|
||||||
let priority = (notification.smseaglePriority) ? notification.smseaglePriority : 0;
|
let priority = (notification.smseaglePriority) ?? 0;
|
||||||
|
|
||||||
let postData = {
|
let postData = {
|
||||||
text: msg,
|
text: msg,
|
||||||
|
@ -88,43 +88,21 @@ class SMSEagle extends NotificationProvider {
|
||||||
priority: priority
|
priority: priority
|
||||||
};
|
};
|
||||||
|
|
||||||
let to = notification.smseagleRecipientTo;
|
if (notification.smseagleRecipientContact) {
|
||||||
let contacts = notification.smseagleRecipientContact;
|
postData["contacts"] = notification.smseagleRecipientContact.split(",").map(Number);
|
||||||
let groups = notification.smseagleRecipientGroup;
|
|
||||||
|
|
||||||
if (contacts) {
|
|
||||||
contacts = contacts.split(",");
|
|
||||||
contacts = contacts.map(e => {
|
|
||||||
return Number(e);
|
|
||||||
});
|
|
||||||
postData["contacts"] = contacts;
|
|
||||||
}
|
}
|
||||||
|
if (notification.smseagleRecipientGroup) {
|
||||||
if (groups) {
|
postData["groups"] = notification.smseagleRecipientGroup.split(",").map(Number);
|
||||||
groups = groups.split(",");
|
|
||||||
groups = groups.map(e => {
|
|
||||||
return Number(e);
|
|
||||||
});
|
|
||||||
postData["groups"] = groups;
|
|
||||||
}
|
}
|
||||||
|
if (notification.smseagleRecipientTo) {
|
||||||
if (to) {
|
postData["to"] = notification.smseagleRecipientTo.split(",");
|
||||||
to = to.split(",");
|
|
||||||
postData["to"] = to;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let endpoint = "/messages/sms";
|
let endpoint = "/messages/sms";
|
||||||
|
|
||||||
if (notification.smseagleMsgType !== "smseagle-sms") {
|
if (notification.smseagleMsgType !== "smseagle-sms") {
|
||||||
|
|
||||||
let duration;
|
postData["duration"] = notification.smseagleDuration ?? 10;
|
||||||
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";
|
endpoint = "/calls/ring";
|
||||||
|
@ -132,7 +110,7 @@ class SMSEagle extends NotificationProvider {
|
||||||
endpoint = "/calls/tts";
|
endpoint = "/calls/tts";
|
||||||
} else if (notification.smseagleMsgType === "smseagle-tts-advanced") {
|
} else if (notification.smseagleMsgType === "smseagle-tts-advanced") {
|
||||||
endpoint = "/calls/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) {
|
if (unqueuedCount) {
|
||||||
return `Sent ${countQueued}/${resp.data.length} Messages Successfully.`;
|
return `Sent ${queuedCount}/${resp.data.length} Messages Successfully.`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return okMsg;
|
return okMsg;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<label for="smseagle-url" class="form-label">{{ $t("smseagleUrl") }}</label>
|
<label for="smseagle-url" class="form-label">{{ $t("smseagleUrl") }}</label>
|
||||||
<input
|
<input
|
||||||
id="smseagle-url" v-model="$parent.notification.smseagleUrl" type="text" minlength="7"
|
id="smseagle-url" v-model="$parent.notification.smseagleUrl" type="text" minlength="7"
|
||||||
class="form-control" placeholder="http://127.0.0.1"
|
class="form-control" placeholder="http://127.0.0.1" required
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
|
@ -16,6 +16,9 @@
|
||||||
<option value="smseagle-apiv1" selected>{{ $t("smseagleApiv1") }} </option>
|
<option value="smseagle-apiv1" selected>{{ $t("smseagleApiv1") }} </option>
|
||||||
<option value="smseagle-apiv2">{{ $t("smseagleApiv2") }} </option>
|
<option value="smseagle-apiv2">{{ $t("smseagleApiv2") }} </option>
|
||||||
</select>
|
</select>
|
||||||
|
<i18n-t tag="div" keypath="smseagleDocs" class="form-text">
|
||||||
|
<a href="https://www.smseagle.eu/api/" target="_blank">https://www.smseagle.eu/api/</a>
|
||||||
|
</i18n-t>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="$parent.notification.smseagleApiType === 'smseagle-apiv1'" class="mb-3">
|
<div v-if="$parent.notification.smseagleApiType === 'smseagle-apiv1'" class="mb-3">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
|
@ -24,6 +27,7 @@
|
||||||
id="smseagle-recipient-type" v-model="$parent.notification.smseagleRecipientType"
|
id="smseagle-recipient-type" v-model="$parent.notification.smseagleRecipientType"
|
||||||
class="form-select"
|
class="form-select"
|
||||||
>
|
>
|
||||||
|
<!-- phone number -->
|
||||||
<option value="smseagle-to" selected>{{ $t("smseagleTo") }}</option>
|
<option value="smseagle-to" selected>{{ $t("smseagleTo") }}</option>
|
||||||
<option value="smseagle-group">{{ $t("smseagleGroup") }}</option>
|
<option value="smseagle-group">{{ $t("smseagleGroup") }}</option>
|
||||||
<option value="smseagle-contact">{{ $t("smseagleContact") }}</option>
|
<option value="smseagle-contact">{{ $t("smseagleContact") }}</option>
|
||||||
|
@ -33,9 +37,12 @@
|
||||||
<label for="smseagle-recipient" class="form-label">{{ $t("smseagleRecipient") }}</label>
|
<label for="smseagle-recipient" class="form-label">{{ $t("smseagleRecipient") }}</label>
|
||||||
<input id="smseagle-recipient" v-model="$parent.notification.smseagleRecipient" type="text" class="form-control" required>
|
<input id="smseagle-recipient" v-model="$parent.notification.smseagleRecipient" type="text" class="form-control" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div
|
||||||
|
v-if="$parent.notification.smseagleMsgType === 'smseagle-sms'
|
||||||
|
|| $parent.notification.smseagleRecipientType !== 'smseagle-to'" class="mb-3"
|
||||||
|
>
|
||||||
<label for="smseagle-priority" class="form-label">{{ $t("smseaglePriority") }}</label>
|
<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">
|
<input id="smseagle-priority" v-model="$parent.notification.smseaglePriority" type="number" class="form-control" min="0" max="9" step="1" placeholder="0" required>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="$parent.notification.smseagleMsgType === 'smseagle-sms'
|
v-if="$parent.notification.smseagleMsgType === 'smseagle-sms'
|
||||||
|
@ -71,31 +78,32 @@
|
||||||
|
|
||||||
<div v-if="$parent.notification.smseagleApiType === 'smseagle-apiv2'" class="mb-3">
|
<div v-if="$parent.notification.smseagleApiType === 'smseagle-apiv2'" class="mb-3">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="smseagle-recipient-type" class="form-label">{{ $t("smseagleRecipient") }}</label>
|
<!-- phone number -->
|
||||||
|
<label for="smseagle-recipient-to" class="form-label">{{ $t("smseagleTo") }}</label>
|
||||||
|
<input id="smseagle-recipient-to" v-model="$parent.notification.smseagleRecipientTo" type="text" class="form-control">
|
||||||
|
<i18n-t tag="div" keypath="smseagleComma" class="form-text" />
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="smseagle-recipient" class="form-label">{{ $t("smseagleTo") }}</label>
|
<label for="smseagle-recipient-group" class="form-label">{{ $t("smseagleGroupV2") }}</label>
|
||||||
<input id="smseagle-recipient" v-model="$parent.notification.smseagleRecipientTo" type="text" class="form-control">
|
<input id="smseagle-recipient-group" v-model="$parent.notification.smseagleRecipientGroup" type="text" class="form-control">
|
||||||
|
<i18n-t tag="div" keypath="smseagleComma" class="form-text" />
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="smseagle-recipient" class="form-label">{{ $t("smseagleGroupV2") }}</label>
|
<label for="smseagle-recipient-contact" class="form-label">{{ $t("smseagleContactV2") }}</label>
|
||||||
<input id="smseagle-recipient" v-model="$parent.notification.smseagleRecipientGroup" type="text" class="form-control">
|
<input id="smseagle-recipient-contact" v-model="$parent.notification.smseagleRecipientContact" type="text" class="form-control">
|
||||||
|
<i18n-t tag="div" keypath="smseagleComma" class="form-text" />
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="smseagle-recipient" class="form-label">{{ $t("smseagleContactV2") }}</label>
|
<label for="smseagle-priority-v2" class="form-label">{{ $t("smseaglePriority") }}</label>
|
||||||
<input id="smseagle-recipient" v-model="$parent.notification.smseagleRecipientContact" type="text" class="form-control">
|
<input id="smseagle-priority-v2" v-model="$parent.notification.smseaglePriority" type="number" class="form-control" min="0" max="9" step="1" placeholder="0">
|
||||||
</div>
|
|
||||||
<div class="mb-3">
|
|
||||||
<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>
|
||||||
<div class="mb-3 form-check form-switch">
|
<div class="mb-3 form-check form-switch">
|
||||||
<label for="smseagle-encoding" class="form-label">{{ $t("smseagleEncoding") }}</label>
|
<label for="smseagle-encoding-v2" class="form-label">{{ $t("smseagleEncoding") }}</label>
|
||||||
<input id="smseagle-encoding" v-model="$parent.notification.smseagleEncoding" type="checkbox" class="form-check-input">
|
<input id="smseagle-encoding-v2" v-model="$parent.notification.smseagleEncoding" type="checkbox" class="form-check-input">
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="smseagle-msg-type" class="form-label">{{ $t("smseagleMsgType") }} </label>
|
<label for="smseagle-msg-type-v2" class="form-label">{{ $t("smseagleMsgType") }} </label>
|
||||||
<select id="smseagle-msg-type" v-model="$parent.notification.smseagleMsgType" class="form-select">
|
<select id="smseagle-msg-type-v2" v-model="$parent.notification.smseagleMsgType" class="form-select">
|
||||||
<option value="smseagle-sms" selected>{{ $t("smseagleMsgSms") }} </option>
|
<option value="smseagle-sms" selected>{{ $t("smseagleMsgSms") }} </option>
|
||||||
<option value="smseagle-ring">{{ $t("smseagleMsgRing") }} </option>
|
<option value="smseagle-ring">{{ $t("smseagleMsgRing") }} </option>
|
||||||
<option value="smseagle-tts">{{ $t("smseagleMsgTts") }} </option>
|
<option value="smseagle-tts">{{ $t("smseagleMsgTts") }} </option>
|
||||||
|
@ -103,12 +111,12 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</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>
|
<label for="smseagle-duration-v2" 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">
|
<input id="smseagle-duration-v2" v-model="$parent.notification.smseagleDuration" type="number" class="form-control" min="0" max="30" step="1" placeholder="10">
|
||||||
</div>
|
</div>
|
||||||
<div v-if="$parent.notification.smseagleMsgType === 'smseagle-tts-advanced'" class="mb-3">
|
<div v-if="$parent.notification.smseagleMsgType === 'smseagle-tts-advanced'" class="mb-3">
|
||||||
<label for="smseagle-tts-model" class="form-label">{{ $t("smseagleTtsModel") }} </label>
|
<label for="smseagle-tts-model-v2" 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-v2" v-model="$parent.notification.smseagleTtsModel" type="number" class="form-control" placeholder="1" required>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -763,18 +763,20 @@
|
||||||
"smseagleRecipient": "Recipient(s) (multiple must be separated with comma)",
|
"smseagleRecipient": "Recipient(s) (multiple must be separated with comma)",
|
||||||
"smseagleToken": "API Access token",
|
"smseagleToken": "API Access token",
|
||||||
"smseagleUrl": "Your SMSEagle device URL",
|
"smseagleUrl": "Your SMSEagle device URL",
|
||||||
"smseagleEncoding": "Send as Unicode",
|
"smseagleEncoding": "Send as Unicode (default=GSM-7)",
|
||||||
"smseaglePriority": "Message priority (0-9, default = 0)",
|
"smseaglePriority": "Message priority (0-9, highest priority = 9)",
|
||||||
"smseagleMsgType": "Message type",
|
"smseagleMsgType": "Message type",
|
||||||
"smseagleMsgSms": "Sms message (default)",
|
"smseagleMsgSms": "Sms message (default)",
|
||||||
"smseagleMsgRing": "Ring call",
|
"smseagleMsgRing": "Ring call",
|
||||||
"smseagleMsgTts": "Text-to-speech call",
|
"smseagleMsgTts": "Text-to-speech call",
|
||||||
"smseagleMsgTtsAdvanced": "Text-to-speech Advanced call",
|
"smseagleMsgTtsAdvanced": "Text-to-speech Advanced call",
|
||||||
"smseagleDuration": "Duration (default=10)",
|
"smseagleDuration": "Duration (in seconds)",
|
||||||
"smseagleTtsModel": "Text-to-speech model ID",
|
"smseagleTtsModel": "Text-to-speech model ID",
|
||||||
"smseagleApiType": "API version",
|
"smseagleApiType": "API version",
|
||||||
"smseagleApiv1": "APIv1 (for existing projects and backward compatibility)",
|
"smseagleApiv1": "APIv1 (for existing projects and backward compatibility)",
|
||||||
"smseagleApiv2": "APIv2 (recommended for new integrations)",
|
"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}",
|
"smspartnerApiurl": "You can find your API key in your dashboard at {0}",
|
||||||
"smspartnerPhoneNumber": "Phone number(s)",
|
"smspartnerPhoneNumber": "Phone number(s)",
|
||||||
"smspartnerPhoneNumberHelptext": "The number must be in the international format {0}, {1}. Multiple numbers must be separated by {2}",
|
"smspartnerPhoneNumberHelptext": "The number must be in the international format {0}, {1}. Multiple numbers must be separated by {2}",
|
||||||
|
|
Loading…
Add table
Reference in a new issue