Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New notification provider: SMS Partner API #4769

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions server/notification-providers/smspartner.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ class SMSPartner extends NotificationProvider {
const url = "https://api.smspartner.fr/v1/send";

try {
//Lets remove non ascii char
let cleanMsg = msg.replace(/[^\x00-\x7F]/g, "");
// smspartner does not support non ascii characters and only a maximum 639 characters
let cleanMsg = msg.replace(/[^\x00-\x7F]/g, "").substring(0, 639);

let data = {
"apiKey": notification.smspartnerApikey,
"gamme": 1,
"sender": notification.smspartnerSenderName.substring(0, 11),
"phoneNumbers": notification.smspartnerPhoneNumber,
"message": cleanMsg.substring(0, 639)
"message": cleanMsg,
};

let config = {
Expand All @@ -34,8 +33,7 @@ class SMSPartner extends NotificationProvider {
let resp = await axios.post(url, data, config);

if (resp.data.success !== true) {
let error = "Something gone wrong. Api returned " + resp.data.response.status + ".";
this.throwGeneralAxiosError(error);
throw Error(`Api returned ${resp.data.response.status}.`);
}

return okMsg;
Expand Down
18 changes: 13 additions & 5 deletions src/components/notifications/SMSPartner.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
<template>
<div class="mb-3">
<label for="smspartner-key" class="form-label">{{ $t("smspartnerApikey") }}</label>
<label for="smspartner-key" class="form-label">{{ $t("API Key") }}</label>
<HiddenInput id="smspartner-key" v-model="$parent.notification.smspartnerApikey" :required="true" autocomplete="new-password"></HiddenInput>
<div class="form-text">
{{ $t("smspartnerApiurl") }}
<a href="https://my.smspartner.fr/dashboard/api" target="_blank">https://my.smspartner.fr/dashboard/api</a>
<i18n-t keypath="smspartnerApiurl" as="div" class="form-text">
<a href="https://my.smspartner.fr/dashboard/api" target="_blank">https://my.smspartner.fr/dashboard/api</a>
CommanderStorm marked this conversation as resolved.
Show resolved Hide resolved
</i18n-t>
</div>
</div>
<div class="mb-3">
<label for="smspartner-phone-number" class="form-label">{{ $t("smspartnerPhoneNumber") }}</label>
nicolasverlhiac marked this conversation as resolved.
Show resolved Hide resolved
<input id="smspartner-phone-number" v-model="$parent.notification.smspartnerPhoneNumber" type="text" class="form-control" required>
<input id="smspartner-phone-number" v-model="$parent.notification.smspartnerPhoneNumber" type="text" minlength="3" maxlength="20" pattern="^[\d+,]+$" class="form-control" required>
<div class="form-text">
<i18n-t keypath="multiple numbers must be separated by" as="div" class="form-text">
CommanderStorm marked this conversation as resolved.
Show resolved Hide resolved
<code>+336xxxxxxxx</code>
<code>+496xxxxxxxx</code>
<code>,</code>
</i18n-t>
</div>
</div>
<div class="mb-3">
<label for="smspartner-sender-name" class="form-label">{{ $t("smspartnerSenderName") }}</label>
<input id="smspartner-sender-name" v-model="$parent.notification.smspartnerSenderName" type="text" minlength="3" maxlength="11" class="form-control">
<input id="smspartner-sender-name" v-model="$parent.notification.smspartnerSenderName" type="text" minlength="3" maxlength="11" pattern="^[a-zA-Z0-9]*$" class="form-control" required>
<div class="form-text">
{{ $t("smspartnerSenderNameInfo") }}
</div>
Expand Down
8 changes: 4 additions & 4 deletions src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -753,11 +753,11 @@
"smseagleUrl": "Your SMSEagle device URL",
"smseagleEncoding": "Send as Unicode",
"smseaglePriority": "Message priority (0-9, default = 0)",
"smspartnerApikey": "API Key",
"smspartnerApiurl": "Find your API key in your dashboard: ",
"smspartnerPhoneNumber": "Phone number(s) (multiple numbers, separate by `,`)",
"smspartnerApiurl": "You can find your API key in your dashboard at {0}",
"smspartnerPhoneNumber": "Phone number(s)",
"multiple numbers must be separated by": "The number must be in the international format {0}, {1}. Multiple numbers must be separated by {2}",
CommanderStorm marked this conversation as resolved.
Show resolved Hide resolved
"smspartnerSenderName": "SMS Sender Name",
"smspartnerSenderNameInfo": "Must be between 3 and 11 inclusive and must not contain any special characters.",
"smspartnerSenderNameInfo": "Must be between 3..=11 regular characters",
"Recipient Number": "Recipient Number",
"From Name/Number": "From Name/Number",
"Leave blank to use a shared sender number.": "Leave blank to use a shared sender number.",
Expand Down
Loading