|
|
@ -8,6 +8,14 @@ class PromoSMS extends NotificationProvider {
|
|
|
|
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
|
|
|
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
|
|
|
let okMsg = "Sent Successfully.";
|
|
|
|
let okMsg = "Sent Successfully.";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (notification.promosmsAllowLongSMS === undefined) {
|
|
|
|
|
|
|
|
notification.promosmsAllowLongSMS = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: Add option for enabling special characters. It will decrese message max length from 160 to 70 chars.
|
|
|
|
|
|
|
|
//Lets remove non ascii char
|
|
|
|
|
|
|
|
let cleanMsg = msg.replace(/[^\x00-\x7F]/g, "");
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
let config = {
|
|
|
|
let config = {
|
|
|
|
headers: {
|
|
|
|
headers: {
|
|
|
@ -18,8 +26,9 @@ class PromoSMS extends NotificationProvider {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
let data = {
|
|
|
|
let data = {
|
|
|
|
"recipients": [ notification.promosmsPhoneNumber ],
|
|
|
|
"recipients": [ notification.promosmsPhoneNumber ],
|
|
|
|
//Lets remove non ascii char
|
|
|
|
//Trim message to maximum length of 1 SMS or 4 if we allowed long messages
|
|
|
|
"text": msg.replace(/[^\x00-\x7F]/g, ""),
|
|
|
|
"text": notification.promosmsAllowLongSMS ? cleanMsg.substring(0, 639) : cleanMsg.substring(0, 159),
|
|
|
|
|
|
|
|
"long-sms": notification.promosmsAllowLongSMS,
|
|
|
|
"type": Number(notification.promosmsSMSType),
|
|
|
|
"type": Number(notification.promosmsSMSType),
|
|
|
|
"sender": notification.promosmsSenderName
|
|
|
|
"sender": notification.promosmsSenderName
|
|
|
|
};
|
|
|
|
};
|
|
|
|