Merge c03fda0d73 into 9169a647cb
This commit is contained in:
commit
3200121d23
51
server/notification-providers/mobivatesms.js
Normal file
51
server/notification-providers/mobivatesms.js
Normal file
@ -0,0 +1,51 @@
|
||||
const NotificationProvider = require("./notification-provider");
|
||||
const axios = require("axios");
|
||||
|
||||
class MobivateSMS extends NotificationProvider {
|
||||
name = "MobivateSMS";
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||
const okMsg = "Sent Successfully.";
|
||||
const url = "https://vortex.mobivatebulksms.com/send/batch";
|
||||
|
||||
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 = {
|
||||
originator: notification.mobivateOriginator.substring(0, 15),
|
||||
recipients: notification.mobivateRecipients
|
||||
.split(",")
|
||||
.map((n) => n.replace(/[^0-9]/g, ""))
|
||||
.filter((n) => n.length >= 9)
|
||||
.map((recipient) => ({ recipient })),
|
||||
text: cleanMsg,
|
||||
};
|
||||
|
||||
let config = {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"cache-control": "no-cache",
|
||||
Accept: "application/json",
|
||||
Authorization: "Bearer " + notification.mobivateApikey,
|
||||
},
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
|
||||
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 = MobivateSMS;
|
||||
@ -28,6 +28,7 @@ const Line = require("./notification-providers/line");
|
||||
const LunaSea = require("./notification-providers/lunasea");
|
||||
const Matrix = require("./notification-providers/matrix");
|
||||
const Mattermost = require("./notification-providers/mattermost");
|
||||
const MobivateSMS = require("./notification-providers/mobivatesms");
|
||||
const NextcloudTalk = require("./notification-providers/nextcloudtalk");
|
||||
const Nostr = require("./notification-providers/nostr");
|
||||
const Ntfy = require("./notification-providers/ntfy");
|
||||
@ -128,6 +129,7 @@ class Notification {
|
||||
new LunaSea(),
|
||||
new Matrix(),
|
||||
new Mattermost(),
|
||||
new MobivateSMS(),
|
||||
new NextcloudTalk(),
|
||||
new Nostr(),
|
||||
new Ntfy(),
|
||||
|
||||
@ -267,6 +267,7 @@ export default {
|
||||
Elks: "46elks",
|
||||
Cellsynt: "Cellsynt",
|
||||
gtxmessaging: "GtxMessaging",
|
||||
MobivateSMS: "Mobivate SMS",
|
||||
octopush: "Octopush",
|
||||
Onesender: "Onesender",
|
||||
SevenIO: "SevenIO",
|
||||
|
||||
53
src/components/notifications/MobivateSMS.vue
Normal file
53
src/components/notifications/MobivateSMS.vue
Normal file
@ -0,0 +1,53 @@
|
||||
<template>
|
||||
<div class="mb-3">
|
||||
<label for="mobivate-key" class="form-label">
|
||||
{{ $t("API Key") }}
|
||||
<span style="color: red"><sup>*</sup></span>
|
||||
</label>
|
||||
<HiddenInput
|
||||
id="mobivate-key"
|
||||
v-model="$parent.notification.mobivateApikey"
|
||||
:required="true"
|
||||
autocomplete="new-password"
|
||||
></HiddenInput>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="mobivate-recipients" class="form-label">{{ $t("Recipients") }}</label>
|
||||
<input
|
||||
id="mobivate-recipients"
|
||||
v-model="$parent.notification.mobivateRecipients"
|
||||
type="text"
|
||||
minlength="3"
|
||||
maxlength="20"
|
||||
pattern="^[\d+,]+$"
|
||||
class="form-control"
|
||||
required
|
||||
/>
|
||||
<div class="form-text">
|
||||
<p>{{ $t("Comma separated list of numbers in international format. (eg. 447930000000,447930000001)") }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="mobivate-originator" class="form-label">{{ $t("Originator") }}</label>
|
||||
<input
|
||||
id="mobivate-originator"
|
||||
v-model="$parent.notification.mobivateOriginator"
|
||||
type="text"
|
||||
minlength="3"
|
||||
maxlength="15"
|
||||
pattern="^[a-zA-Z0-9]*$"
|
||||
class="form-control"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import HiddenInput from "../HiddenInput.vue";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
HiddenInput,
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@ -27,6 +27,7 @@ import Line from "./Line.vue";
|
||||
import LunaSea from "./LunaSea.vue";
|
||||
import Matrix from "./Matrix.vue";
|
||||
import Mattermost from "./Mattermost.vue";
|
||||
import MobivateSMS from "./MobivateSMS.vue";
|
||||
import NextcloudTalk from "./NextcloudTalk.vue";
|
||||
import Nostr from "./Nostr.vue";
|
||||
import Ntfy from "./Ntfy.vue";
|
||||
@ -116,6 +117,7 @@ const NotificationFormList = {
|
||||
lunasea: LunaSea,
|
||||
matrix: Matrix,
|
||||
mattermost: Mattermost,
|
||||
MobivateSMS: MobivateSMS,
|
||||
nextcloudtalk: NextcloudTalk,
|
||||
nostr: Nostr,
|
||||
ntfy: Ntfy,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user