|
|
@ -1,9 +1,12 @@
|
|
|
|
const NotificationProvider = require("./notification-provider");
|
|
|
|
const NotificationProvider = require("./notification-provider");
|
|
|
|
const axios = require("axios");
|
|
|
|
const { DOWN, UP } = require("../../src/util");
|
|
|
|
|
|
|
|
const { default: axios } = require("axios");
|
|
|
|
|
|
|
|
const Crypto = require("crypto");
|
|
|
|
|
|
|
|
const qs = require("qs");
|
|
|
|
|
|
|
|
|
|
|
|
class CellsyntMobileServices extends NotificationProvider {
|
|
|
|
class CellsyntMobileServices extends NotificationProvider {
|
|
|
|
|
|
|
|
|
|
|
|
name = "cellsyntmobileservices";
|
|
|
|
name = "CellsyntMobileServices";
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
* @inheritdoc
|
|
|
@ -12,34 +15,16 @@ class CellsyntMobileServices extends NotificationProvider {
|
|
|
|
let okMsg = "Sent Successfully.";
|
|
|
|
let okMsg = "Sent Successfully.";
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
let config = {
|
|
|
|
|
|
|
|
headers: {
|
|
|
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
|
|
|
"Authorization": "Basic " + Buffer.from(notification.clicksendsmsLogin + ":" + notification.clicksendsmsPassword).toString("base64"),
|
|
|
|
|
|
|
|
"Accept": "text/json",
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
let data = {
|
|
|
|
let data = {
|
|
|
|
/* messages: [
|
|
|
|
params: {
|
|
|
|
{
|
|
|
|
|
|
|
|
"body": msg.replace(/[^\x00-\x7F]/g, ""),
|
|
|
|
|
|
|
|
"to": notification.clicksendsmsToNumber,
|
|
|
|
|
|
|
|
"source": "uptime-kuma",
|
|
|
|
|
|
|
|
"from": notification.clicksendsmsSenderName,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]*/
|
|
|
|
|
|
|
|
messages: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//"from": notification.clicksendsmsSenderName,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Your username (received when account is setup).
|
|
|
|
/* Your username (received when account is setup).
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
"username": "abc123",
|
|
|
|
"username": notification.cellsyntLogin,
|
|
|
|
|
|
|
|
|
|
|
|
/* Your password to use together with the username for
|
|
|
|
/* Your password to use together with the username for
|
|
|
|
authentication (received when account is setup).
|
|
|
|
authentication (received when account is setup).
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
"password": "abc123",
|
|
|
|
"password": notification.cellsyntPassword,
|
|
|
|
|
|
|
|
|
|
|
|
/* Recipient's telephone number on international format with
|
|
|
|
/* Recipient's telephone number on international format with
|
|
|
|
leading 00 followed by country code, e.g. 00447920110000 for
|
|
|
|
leading 00 followed by country code, e.g. 00447920110000 for
|
|
|
@ -47,7 +32,7 @@ class CellsyntMobileServices extends NotificationProvider {
|
|
|
|
To send the same message to multiple recipients, separate
|
|
|
|
To send the same message to multiple recipients, separate
|
|
|
|
numbers with comma. Max 25000 recipients per HTTP request.
|
|
|
|
numbers with comma. Max 25000 recipients per HTTP request.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
"destination": "0046738387444",
|
|
|
|
"destination": notification.cellsyntDestination,
|
|
|
|
|
|
|
|
|
|
|
|
"text": msg.replace(/[^\x00-\x7F]/g, ""),
|
|
|
|
"text": msg.replace(/[^\x00-\x7F]/g, ""),
|
|
|
|
/* Character set text and other data is sent as in the HTTP
|
|
|
|
/* Character set text and other data is sent as in the HTTP
|
|
|
@ -58,7 +43,7 @@ class CellsyntMobileServices extends NotificationProvider {
|
|
|
|
/* Controls the originator type the message should be sent with.
|
|
|
|
/* Controls the originator type the message should be sent with.
|
|
|
|
Possible values: numeric, shortcode and alpha.
|
|
|
|
Possible values: numeric, shortcode and alpha.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
"originatortype": "alpha",
|
|
|
|
"originatortype": notification.Originatortype,
|
|
|
|
|
|
|
|
|
|
|
|
/* Identifier which will be visible on recipient's mobile phone as
|
|
|
|
/* Identifier which will be visible on recipient's mobile phone as
|
|
|
|
originator of the message. Allowed values and function depends
|
|
|
|
originator of the message. Allowed values and function depends
|
|
|
@ -83,7 +68,7 @@ class CellsyntMobileServices extends NotificationProvider {
|
|
|
|
originators
|
|
|
|
originators
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
//"originator": "uptime-kuma",
|
|
|
|
//"originator": "uptime-kuma",
|
|
|
|
"originator": notification.clicksendsmsSenderName,
|
|
|
|
"originator": notification.cellsyntOriginator,
|
|
|
|
/* Type of message that should be sent. Possible values: text
|
|
|
|
/* Type of message that should be sent. Possible values: text
|
|
|
|
(default), binary and unicode */
|
|
|
|
(default), binary and unicode */
|
|
|
|
"type": "text",
|
|
|
|
"type": "text",
|
|
|
@ -92,7 +77,7 @@ class CellsyntMobileServices extends NotificationProvider {
|
|
|
|
needed (default value is 1, see Long SMS). Maximum value is 6
|
|
|
|
needed (default value is 1, see Long SMS). Maximum value is 6
|
|
|
|
(i.e. max 153 x 6 = 918 characters).
|
|
|
|
(i.e. max 153 x 6 = 918 characters).
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
"allowconcat": 1,
|
|
|
|
"allowconcat": notification.cellsyntAllowLongSMS?6:1,
|
|
|
|
|
|
|
|
|
|
|
|
/* Can be used if you want to prevent a message from being
|
|
|
|
/* Can be used if you want to prevent a message from being
|
|
|
|
delivered after a certain time, e.g. 9 PM the same evening if
|
|
|
|
delivered after a certain time, e.g. 9 PM the same evening if
|
|
|
@ -137,12 +122,26 @@ class CellsyntMobileServices extends NotificationProvider {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
//"pid": "",
|
|
|
|
//"pid": "",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
let resp = await axios.post("https://se-1.cellsynt.net/sms.php", data, config);
|
|
|
|
try {
|
|
|
|
console.log(resp);
|
|
|
|
if (heartbeatJSON != null) {
|
|
|
|
if (resp.data.data.messages[0].status !== "SUCCESS") {
|
|
|
|
var d = new Date(heartbeatJSON["time"]),
|
|
|
|
let error = "Something gone wrong. Api returned " + resp.data.data.messages[0].status + ".";
|
|
|
|
dformat = [d.getMonth()+1,
|
|
|
|
|
|
|
|
d.getDate(),
|
|
|
|
|
|
|
|
d.getFullYear()].join('/')+' '+
|
|
|
|
|
|
|
|
[d.getHours(),
|
|
|
|
|
|
|
|
d.getMinutes()].join(':');
|
|
|
|
|
|
|
|
msg = dformat+" - "+msg;
|
|
|
|
|
|
|
|
data.params.text = msg.replace(/[^\x00-\x7F]/g, "");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let resp = await axios.post("https://se-1.cellsynt.net/sms.php", null, data);
|
|
|
|
|
|
|
|
if(typeof resp.data == undefined || resp.data == null || resp.data.includes("Error")) {
|
|
|
|
|
|
|
|
this.throwGeneralAxiosError(resp.data);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}catch (error) {
|
|
|
|
this.throwGeneralAxiosError(error);
|
|
|
|
this.throwGeneralAxiosError(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|