|
|
@ -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,137 +15,133 @@ 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: {
|
|
|
|
{
|
|
|
|
/* Your username (received when account is setup).
|
|
|
|
"body": msg.replace(/[^\x00-\x7F]/g, ""),
|
|
|
|
*/
|
|
|
|
"to": notification.clicksendsmsToNumber,
|
|
|
|
"username": notification.cellsyntLogin,
|
|
|
|
"source": "uptime-kuma",
|
|
|
|
|
|
|
|
"from": notification.clicksendsmsSenderName,
|
|
|
|
/* Your password to use together with the username for
|
|
|
|
}
|
|
|
|
authentication (received when account is setup).
|
|
|
|
]*/
|
|
|
|
*/
|
|
|
|
messages: [
|
|
|
|
"password": notification.cellsyntPassword,
|
|
|
|
{
|
|
|
|
|
|
|
|
//"from": notification.clicksendsmsSenderName,
|
|
|
|
/* Recipient's telephone number on international format with
|
|
|
|
|
|
|
|
leading 00 followed by country code, e.g. 00447920110000 for
|
|
|
|
/* Your username (received when account is setup).
|
|
|
|
UK number 07920 110 000 (max 17 digits in total).
|
|
|
|
*/
|
|
|
|
To send the same message to multiple recipients, separate
|
|
|
|
"username": "abc123",
|
|
|
|
numbers with comma. Max 25000 recipients per HTTP request.
|
|
|
|
|
|
|
|
*/
|
|
|
|
/* Your password to use together with the username for
|
|
|
|
"destination": notification.cellsyntDestination,
|
|
|
|
authentication (received when account is setup).
|
|
|
|
|
|
|
|
*/
|
|
|
|
"text": msg.replace(/[^\x00-\x7F]/g, ""),
|
|
|
|
"password": "abc123",
|
|
|
|
/* Character set text and other data is sent as in the HTTP
|
|
|
|
|
|
|
|
request. Possible values: ISO-8859-1 (default) and UTF-8
|
|
|
|
/* Recipient's telephone number on international format with
|
|
|
|
*/
|
|
|
|
leading 00 followed by country code, e.g. 00447920110000 for
|
|
|
|
"charset": "UTF-8",
|
|
|
|
UK number 07920 110 000 (max 17 digits in total).
|
|
|
|
|
|
|
|
To send the same message to multiple recipients, separate
|
|
|
|
/* Controls the originator type the message should be sent with.
|
|
|
|
numbers with comma. Max 25000 recipients per HTTP request.
|
|
|
|
Possible values: numeric, shortcode and alpha.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
"destination": "0046738387444",
|
|
|
|
"originatortype": notification.Originatortype,
|
|
|
|
|
|
|
|
|
|
|
|
"text": msg.replace(/[^\x00-\x7F]/g, ""),
|
|
|
|
/* Identifier which will be visible on recipient's mobile phone as
|
|
|
|
/* Character set text and other data is sent as in the HTTP
|
|
|
|
originator of the message. Allowed values and function depends
|
|
|
|
request. Possible values: ISO-8859-1 (default) and UTF-8
|
|
|
|
on parameter originatortype's value according to below:
|
|
|
|
*/
|
|
|
|
** numeric **
|
|
|
|
"charset": "UTF-8",
|
|
|
|
Numeric value (max 15 digits) with telephone number on
|
|
|
|
|
|
|
|
international format without leading 00 (example UK number
|
|
|
|
/* Controls the originator type the message should be sent with.
|
|
|
|
07920 110 000 should be set as 447920110000). Receiving
|
|
|
|
Possible values: numeric, shortcode and alpha.
|
|
|
|
mobile phone will add a leading + sign and thus see the
|
|
|
|
*/
|
|
|
|
originator as a normal mobile phone number (+447920110000).
|
|
|
|
"originatortype": "alpha",
|
|
|
|
Therefore it is also possible to reply to the message.
|
|
|
|
|
|
|
|
** shortcode **
|
|
|
|
/* Identifier which will be visible on recipient's mobile phone as
|
|
|
|
Numerical value (max 15 digits). Used to set a shortcode in an
|
|
|
|
originator of the message. Allowed values and function depends
|
|
|
|
operator network as originator (i.e. will be shown without leading
|
|
|
|
on parameter originatortype's value according to below:
|
|
|
|
+ sign, e.g. 72456).
|
|
|
|
** numeric **
|
|
|
|
** alpha **
|
|
|
|
Numeric value (max 15 digits) with telephone number on
|
|
|
|
3Send SMS
|
|
|
|
international format without leading 00 (example UK number
|
|
|
|
Alphanumeric string (max 11 characters). The following
|
|
|
|
07920 110 000 should be set as 447920110000). Receiving
|
|
|
|
characters are guaranteed to work: a-z, A-Z and 0-9. Other
|
|
|
|
mobile phone will add a leading + sign and thus see the
|
|
|
|
characters may work but functionality can not be guaranteed.
|
|
|
|
originator as a normal mobile phone number (+447920110000).
|
|
|
|
Recipients can not reply to messages with alphanumeric
|
|
|
|
Therefore it is also possible to reply to the message.
|
|
|
|
originators
|
|
|
|
** shortcode **
|
|
|
|
*/
|
|
|
|
Numerical value (max 15 digits). Used to set a shortcode in an
|
|
|
|
//"originator": "uptime-kuma",
|
|
|
|
operator network as originator (i.e. will be shown without leading
|
|
|
|
"originator": notification.cellsyntOriginator,
|
|
|
|
+ sign, e.g. 72456).
|
|
|
|
/* Type of message that should be sent. Possible values: text
|
|
|
|
** alpha **
|
|
|
|
(default), binary and unicode */
|
|
|
|
3Send SMS
|
|
|
|
"type": "text",
|
|
|
|
Alphanumeric string (max 11 characters). The following
|
|
|
|
|
|
|
|
characters are guaranteed to work: a-z, A-Z and 0-9. Other
|
|
|
|
/* Maximum number of SMS permitted to be linked together when
|
|
|
|
characters may work but functionality can not be guaranteed.
|
|
|
|
needed (default value is 1, see Long SMS). Maximum value is 6
|
|
|
|
Recipients can not reply to messages with alphanumeric
|
|
|
|
(i.e. max 153 x 6 = 918 characters).
|
|
|
|
originators
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
"allowconcat": notification.cellsyntAllowLongSMS?6:1,
|
|
|
|
//"originator": "uptime-kuma",
|
|
|
|
|
|
|
|
"originator": notification.clicksendsmsSenderName,
|
|
|
|
/* Can be used if you want to prevent a message from being
|
|
|
|
/* Type of message that should be sent. Possible values: text
|
|
|
|
delivered after a certain time, e.g. 9 PM the same evening if
|
|
|
|
(default), binary and unicode */
|
|
|
|
information thereafter is considered invalid / outdated. If
|
|
|
|
"type": "text",
|
|
|
|
message has not been delivered after the set time (e.g. mobile
|
|
|
|
|
|
|
|
phone was switched off) you will get a delivery receipt with
|
|
|
|
/* Maximum number of SMS permitted to be linked together when
|
|
|
|
status "failed".
|
|
|
|
needed (default value is 1, see Long SMS). Maximum value is 6
|
|
|
|
Value should be given as a Unix timestamp. Different operators
|
|
|
|
(i.e. max 153 x 6 = 918 characters).
|
|
|
|
permit different allowed max values (e.g. 3 days expiry time). If
|
|
|
|
*/
|
|
|
|
a value is set that is above an operator's max allowed time it will
|
|
|
|
"allowconcat": 1,
|
|
|
|
be adjusted to the highest possible value.
|
|
|
|
|
|
|
|
*/
|
|
|
|
/* Can be used if you want to prevent a message from being
|
|
|
|
//"expiry": "9 PM",
|
|
|
|
delivered after a certain time, e.g. 9 PM the same evening if
|
|
|
|
|
|
|
|
information thereafter is considered invalid / outdated. If
|
|
|
|
/* Value can be set to true if message should be sent as "flash
|
|
|
|
message has not been delivered after the set time (e.g. mobile
|
|
|
|
message", i.e. displayed directly on phone screen instead of
|
|
|
|
phone was switched off) you will get a delivery receipt with
|
|
|
|
being saved to inbox. This is identical to setting class=0.
|
|
|
|
status "failed".
|
|
|
|
Please note that support for flash messages cannot be
|
|
|
|
Value should be given as a Unix timestamp. Different operators
|
|
|
|
guaranteed to all operator networks. If flash is not supported the
|
|
|
|
permit different allowed max values (e.g. 3 days expiry time). If
|
|
|
|
message will be sent as a regular text message instead
|
|
|
|
a value is set that is above an operator's max allowed time it will
|
|
|
|
(class=1).
|
|
|
|
be adjusted to the highest possible value.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
//"flash": "",
|
|
|
|
//"expiry": "9 PM",
|
|
|
|
|
|
|
|
|
|
|
|
/* Message class can be set to 0 (flash message), 1 (default, MEspecific), 2 (SIM-specific) or 3 (TE-specific).
|
|
|
|
/* Value can be set to true if message should be sent as "flash
|
|
|
|
*/
|
|
|
|
message", i.e. displayed directly on phone screen instead of
|
|
|
|
//"class": "",
|
|
|
|
being saved to inbox. This is identical to setting class=0.
|
|
|
|
|
|
|
|
Please note that support for flash messages cannot be
|
|
|
|
/* UDH (User Data Header) can be used to send concatenated
|
|
|
|
guaranteed to all operator networks. If flash is not supported the
|
|
|
|
SMS, contain formatting information, convey port numbers as a
|
|
|
|
message will be sent as a regular text message instead
|
|
|
|
mean to cause start of an application etc. The value should be
|
|
|
|
(class=1).
|
|
|
|
given on hexadecimal format for the corresponding bytes you
|
|
|
|
*/
|
|
|
|
wish to send (e.g. AABBCC).
|
|
|
|
//"flash": "",
|
|
|
|
*/
|
|
|
|
|
|
|
|
//"udh": "",
|
|
|
|
/* Message class can be set to 0 (flash message), 1 (default, MEspecific), 2 (SIM-specific) or 3 (TE-specific).
|
|
|
|
|
|
|
|
*/
|
|
|
|
/* Protocol Identifier (specified in GSM 03.40) says how the
|
|
|
|
//"class": "",
|
|
|
|
message should be interpreted. Value should be given on
|
|
|
|
|
|
|
|
hexadecimal format, e.g. 00 for a regular message and 7D
|
|
|
|
/* UDH (User Data Header) can be used to send concatenated
|
|
|
|
(decimal 125) for a configuration message ("ME Data
|
|
|
|
SMS, contain formatting information, convey port numbers as a
|
|
|
|
download").
|
|
|
|
mean to cause start of an application etc. The value should be
|
|
|
|
*/
|
|
|
|
given on hexadecimal format for the corresponding bytes you
|
|
|
|
//"pid": "",
|
|
|
|
wish to send (e.g. AABBCC).
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
//"udh": "",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Protocol Identifier (specified in GSM 03.40) says how the
|
|
|
|
|
|
|
|
message should be interpreted. Value should be given on
|
|
|
|
|
|
|
|
hexadecimal format, e.g. 00 for a regular message and 7D
|
|
|
|
|
|
|
|
(decimal 125) for a configuration message ("ME Data
|
|
|
|
|
|
|
|
download").
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
//"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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|