-
-
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
Draft
jhuseinovic
wants to merge
17
commits into
louislam:master
Choose a base branch
from
jhuseinovic:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+109
β0
Draft
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
ba02c70
MobivateSMS Notification Provider support
jhuseinovic fa5891b
fixes to mobivatesms
jhuseinovic 340c1cc
spaces
jhuseinovic d01787c
instantiate MobivateSMS
jhuseinovic 04b92b3
Adding Mobivate SMS to the list of Notification Providers
jhuseinovic 11c4b2e
oops
jhuseinovic f586428
lets gooo
jhuseinovic ef0fff9
debug
jhuseinovic 5414359
less text
jhuseinovic 8b2b4b0
added to export list
jhuseinovic 7d0a706
added text
jhuseinovic 672f69c
debug
jhuseinovic 13fd827
filter numbers
jhuseinovic c1b15d2
correct format of the recipients
jhuseinovic 635ef0d
removing logs
jhuseinovic 6ec1c8f
Merge branch 'master' into master
CommanderStorm c03fda0
[autofix.ci] apply automated fixes
autofix-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
|
|
||
| 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; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||||||
|
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> | ||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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