Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
51 changes: 51 additions & 0 deletions server/notification-providers/mobivatesms.js
Original file line number Diff line number Diff line change
@@ -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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add an indicator ("...") if we cut off a message.
639 is rather large, but it might still happen


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;
2 changes: 2 additions & 0 deletions server/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -128,6 +129,7 @@ class Notification {
new LunaSea(),
new Matrix(),
new Mattermost(),
new MobivateSMS(),
new NextcloudTalk(),
new Nostr(),
new Ntfy(),
Expand Down
1 change: 1 addition & 0 deletions src/components/NotificationDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ export default {
Elks: "46elks",
Cellsynt: "Cellsynt",
gtxmessaging: "GtxMessaging",
MobivateSMS: "Mobivate SMS",
octopush: "Octopush",
Onesender: "Onesender",
SevenIO: "SevenIO",
Expand Down
53 changes: 53 additions & 0 deletions src/components/notifications/MobivateSMS.vue
Original file line number Diff line number Diff line change
@@ -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>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure that all translations are in en.json as otherwise they cannot be translated

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<p>{{ $t("Comma separated list of numbers in international format. (eg. 447930000000,447930000001)") }}</p>
{{ $t("Comma separated list of numbers in international format. (eg. 447930000000,447930000001)") }}

</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>
2 changes: 2 additions & 0 deletions src/components/notifications/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -116,6 +117,7 @@ const NotificationFormList = {
lunasea: LunaSea,
matrix: Matrix,
mattermost: Mattermost,
MobivateSMS: MobivateSMS,
nextcloudtalk: NextcloudTalk,
nostr: Nostr,
ntfy: Ntfy,
Expand Down
Loading