Use API key instead of persistent token

master
Skylar Ittner 3 years ago
parent db203ea945
commit 3583f61fd7

@ -4,7 +4,7 @@
"matrixuser": "smsbot",
"matrixpass": "hunter2",
"inviteusers": ["@annoyme:matrix.org"],
"smstoken": "Voxtelesys SMS API persistent token goes here",
"smsapikey": "Voxtelesys SMS API key goes here",
"smsfrom": "Voxtelesys DID goes here",
"smsonlyto": ["14061234567"],
"loglevel": "debug",

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