|
|
@ -41,7 +41,7 @@ function checkSMS() {
|
|
|
|
path: '/api/v1/msgs/inbound?unread_only=true',
|
|
|
|
path: '/api/v1/msgs/inbound?unread_only=true',
|
|
|
|
method: 'GET',
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
headers: {
|
|
|
|
"Authorization": "Token token=" + settings.smstoken
|
|
|
|
"Authorization": "Bearer " + settings.smsapikey
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -265,7 +265,7 @@ function sendSMS(number, body, callback) {
|
|
|
|
path: '/api/v1/sms',
|
|
|
|
path: '/api/v1/sms',
|
|
|
|
method: 'POST',
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
headers: {
|
|
|
|
"Authorization": "Token token=" + settings.smstoken,
|
|
|
|
"Authorization": "Bearer " + settings.smsapikey,
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
"Accept": "application/json"
|
|
|
|
"Accept": "application/json"
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -279,6 +279,7 @@ function sendSMS(number, body, callback) {
|
|
|
|
|
|
|
|
|
|
|
|
req.on('error', error => {
|
|
|
|
req.on('error', error => {
|
|
|
|
logger.error(error);
|
|
|
|
logger.error(error);
|
|
|
|
|
|
|
|
callback(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
req.write(data);
|
|
|
|
req.write(data);
|
|
|
@ -334,8 +335,9 @@ client.login("m.login.password", {"user": settings.matrixuser, "password": setti
|
|
|
|
if (matches.length == 1) {
|
|
|
|
if (matches.length == 1) {
|
|
|
|
var tel = matches[0];
|
|
|
|
var tel = matches[0];
|
|
|
|
logger.info("Got message for " + tel + " from " + event.getSender() + ", relaying.");
|
|
|
|
logger.info("Got message for " + tel + " from " + event.getSender() + ", relaying.");
|
|
|
|
sendSMS(tel, event.getContent().body);
|
|
|
|
sendSMS(tel, event.getContent().body, function () {
|
|
|
|
client.sendReadReceipt(event, {});
|
|
|
|
client.sendReadReceipt(event, {});
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|