mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-12 16:44:12 -08:00
New notification provider: SMS Partner API (#4769)
Co-authored-by: Nicolas Verlhiac <nicolas@novariom.com> Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
parent
88b7c047a8
commit
b1e95968c0
46
server/notification-providers/smspartner.js
Normal file
46
server/notification-providers/smspartner.js
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
const NotificationProvider = require("./notification-provider");
|
||||||
|
const axios = require("axios");
|
||||||
|
|
||||||
|
class SMSPartner extends NotificationProvider {
|
||||||
|
name = "SMSPartner";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||||
|
const okMsg = "Sent Successfully.";
|
||||||
|
const url = "https://api.smspartner.fr/v1/send";
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 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,
|
||||||
|
"sender": notification.smspartnerSenderName.substring(0, 11),
|
||||||
|
"phoneNumbers": notification.smspartnerPhoneNumber,
|
||||||
|
"message": cleanMsg,
|
||||||
|
};
|
||||||
|
|
||||||
|
let config = {
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"cache-control": "no-cache",
|
||||||
|
"Accept": "application/json",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let resp = await axios.post(url, data, config);
|
||||||
|
|
||||||
|
if (resp.data.success !== true) {
|
||||||
|
throw Error(`Api returned ${resp.data.response.status}.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return okMsg;
|
||||||
|
} catch (error) {
|
||||||
|
this.throwGeneralAxiosError(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = SMSPartner;
|
|
@ -43,6 +43,7 @@ const RocketChat = require("./notification-providers/rocket-chat");
|
||||||
const SerwerSMS = require("./notification-providers/serwersms");
|
const SerwerSMS = require("./notification-providers/serwersms");
|
||||||
const Signal = require("./notification-providers/signal");
|
const Signal = require("./notification-providers/signal");
|
||||||
const Slack = require("./notification-providers/slack");
|
const Slack = require("./notification-providers/slack");
|
||||||
|
const SMSPartner = require("./notification-providers/smspartner");
|
||||||
const SMSEagle = require("./notification-providers/smseagle");
|
const SMSEagle = require("./notification-providers/smseagle");
|
||||||
const SMTP = require("./notification-providers/smtp");
|
const SMTP = require("./notification-providers/smtp");
|
||||||
const Squadcast = require("./notification-providers/squadcast");
|
const Squadcast = require("./notification-providers/squadcast");
|
||||||
|
@ -123,6 +124,7 @@ class Notification {
|
||||||
new SerwerSMS(),
|
new SerwerSMS(),
|
||||||
new Signal(),
|
new Signal(),
|
||||||
new SMSManager(),
|
new SMSManager(),
|
||||||
|
new SMSPartner(),
|
||||||
new Slack(),
|
new Slack(),
|
||||||
new SMSEagle(),
|
new SMSEagle(),
|
||||||
new SMTP(),
|
new SMTP(),
|
||||||
|
|
|
@ -147,6 +147,7 @@ export default {
|
||||||
"slack": "Slack",
|
"slack": "Slack",
|
||||||
"squadcast": "SquadCast",
|
"squadcast": "SquadCast",
|
||||||
"SMSEagle": "SMSEagle",
|
"SMSEagle": "SMSEagle",
|
||||||
|
"SMSPartner": "SMS Partner",
|
||||||
"smtp": this.$t("smtp"),
|
"smtp": this.$t("smtp"),
|
||||||
"stackfield": "Stackfield",
|
"stackfield": "Stackfield",
|
||||||
"teams": "Microsoft Teams",
|
"teams": "Microsoft Teams",
|
||||||
|
|
39
src/components/notifications/SMSPartner.vue
Normal file
39
src/components/notifications/SMSPartner.vue
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
<template>
|
||||||
|
<div class="mb-3">
|
||||||
|
<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">
|
||||||
|
<i18n-t keypath="smspartnerApiurl" as="div" class="form-text">
|
||||||
|
<a href="https://my.smspartner.fr/dashboard/api" target="_blank">my.smspartner.fr/dashboard/api</a>
|
||||||
|
</i18n-t>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="smspartner-phone-number" class="form-label">{{ $t("smspartnerPhoneNumber") }}</label>
|
||||||
|
<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="smspartnerPhoneNumberHelptext" as="div" class="form-text">
|
||||||
|
<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" pattern="^[a-zA-Z0-9]*$" class="form-control" required>
|
||||||
|
<div class="form-text">
|
||||||
|
{{ $t("smspartnerSenderNameInfo") }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import HiddenInput from "../HiddenInput.vue";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
HiddenInput,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
|
@ -43,6 +43,7 @@ import ServerChan from "./ServerChan.vue";
|
||||||
import SerwerSMS from "./SerwerSMS.vue";
|
import SerwerSMS from "./SerwerSMS.vue";
|
||||||
import Signal from "./Signal.vue";
|
import Signal from "./Signal.vue";
|
||||||
import SMSManager from "./SMSManager.vue";
|
import SMSManager from "./SMSManager.vue";
|
||||||
|
import SMSPartner from "./SMSPartner.vue";
|
||||||
import Slack from "./Slack.vue";
|
import Slack from "./Slack.vue";
|
||||||
import Squadcast from "./Squadcast.vue";
|
import Squadcast from "./Squadcast.vue";
|
||||||
import SMSEagle from "./SMSEagle.vue";
|
import SMSEagle from "./SMSEagle.vue";
|
||||||
|
@ -110,6 +111,7 @@ const NotificationFormList = {
|
||||||
"serwersms": SerwerSMS,
|
"serwersms": SerwerSMS,
|
||||||
"signal": Signal,
|
"signal": Signal,
|
||||||
"SMSManager": SMSManager,
|
"SMSManager": SMSManager,
|
||||||
|
"SMSPartner": SMSPartner,
|
||||||
"slack": Slack,
|
"slack": Slack,
|
||||||
"squadcast": Squadcast,
|
"squadcast": Squadcast,
|
||||||
"SMSEagle": SMSEagle,
|
"SMSEagle": SMSEagle,
|
||||||
|
|
|
@ -753,6 +753,11 @@
|
||||||
"smseagleUrl": "Your SMSEagle device URL",
|
"smseagleUrl": "Your SMSEagle device URL",
|
||||||
"smseagleEncoding": "Send as Unicode",
|
"smseagleEncoding": "Send as Unicode",
|
||||||
"smseaglePriority": "Message priority (0-9, default = 0)",
|
"smseaglePriority": "Message priority (0-9, default = 0)",
|
||||||
|
"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}",
|
||||||
|
"smspartnerSenderName": "SMS Sender Name",
|
||||||
|
"smspartnerSenderNameInfo": "Must be between 3..=11 regular characters",
|
||||||
"Recipient Number": "Recipient Number",
|
"Recipient Number": "Recipient Number",
|
||||||
"From Name/Number": "From Name/Number",
|
"From Name/Number": "From Name/Number",
|
||||||
"Leave blank to use a shared sender number.": "Leave blank to use a shared sender number.",
|
"Leave blank to use a shared sender number.": "Leave blank to use a shared sender number.",
|
||||||
|
|
Loading…
Reference in a new issue