mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-24 07:14:04 +00:00
Make PromoSMS actually working
Make PromoSMS actually working and inform on success only when API return 0
This commit is contained in:
parent
12b5489eb5
commit
dfd63386ba
1 changed files with 12 additions and 12 deletions
|
@ -9,27 +9,27 @@ class PromoSMS extends NotificationProvider {
|
||||||
let okMsg = "Sent Successfully.";
|
let okMsg = "Sent Successfully.";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let buffer = new Buffer(notification.promosmsLogin + ":" + notification.promosmsPassword);
|
|
||||||
let promosmsAuth = buffer.toString('base64');
|
|
||||||
let config = {
|
let config = {
|
||||||
headers: {
|
headers: {
|
||||||
"Authorization": "Basic" + promosmsAuth,
|
"Content-Type": "application/json",
|
||||||
"Content-Type": "application/x-www-form-urlencoded",
|
"Authorization": "Basic " + Buffer.from(notification.promosmsLogin + ":" + notification.promosmsPassword).toString('base64'),
|
||||||
"Accept": "text/json"
|
"Accept": "text/json",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let data = {
|
let data = {
|
||||||
"recipients": [
|
"recipients": [ notification.promosmsPhoneNumber ],
|
||||||
{
|
|
||||||
"recipients": notification.promosmsPhoneNumber
|
|
||||||
}
|
|
||||||
],
|
|
||||||
//Lets remove non ascii char
|
//Lets remove non ascii char
|
||||||
"text": msg.replace(/[^\x00-\x7F]/g, ""),
|
"text": msg.replace(/[^\x00-\x7F]/g, ""),
|
||||||
"type": notification.promosmsSMSType,
|
"type": Number(notification.promosmsSMSType),
|
||||||
"sender": notification.promosmsSenderName
|
"sender": notification.promosmsSenderName
|
||||||
};
|
};
|
||||||
await axios.post("https://promosms.com/api/rest/v3_2/sms", data, config)
|
|
||||||
|
await axios.post("https://promosms.com/api/rest/v3_2/sms", data, config).then(resp => {
|
||||||
|
if (resp.data.response.status !== 0) {
|
||||||
|
let error = "Something gone wrong. Api returned " + resp.data.response.status + ".";
|
||||||
|
this.throwGeneralAxiosError(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return okMsg;
|
return okMsg;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
Loading…
Reference in a new issue