-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Mobivate SMS Notification plugin #6451
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
base: master
Are you sure you want to change the base?
Changes from 15 commits
ba02c70
fa5891b
340c1cc
d01787c
04b92b3
11c4b2e
f586428
ef0fff9
5414359
8b2b4b0
7d0a706
672f69c
13fd827
c1b15d2
635ef0d
6ec1c8f
c03fda0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| 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})), | ||
|
Check failure on line 20 in server/notification-providers/mobivatesms.js
|
||
|
||
| "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; | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,27 @@ | ||||||
| <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> | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| </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> | ||||||
There was a problem hiding this comment.
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