Use API key instead of persistent token
This commit is contained in:
parent
db203ea945
commit
3583f61fd7
@ -4,7 +4,7 @@
|
|||||||
"matrixuser": "smsbot",
|
"matrixuser": "smsbot",
|
||||||
"matrixpass": "hunter2",
|
"matrixpass": "hunter2",
|
||||||
"inviteusers": ["@annoyme:matrix.org"],
|
"inviteusers": ["@annoyme:matrix.org"],
|
||||||
"smstoken": "Voxtelesys SMS API persistent token goes here",
|
"smsapikey": "Voxtelesys SMS API key goes here",
|
||||||
"smsfrom": "Voxtelesys DID goes here",
|
"smsfrom": "Voxtelesys DID goes here",
|
||||||
"smsonlyto": ["14061234567"],
|
"smsonlyto": ["14061234567"],
|
||||||
"loglevel": "debug",
|
"loglevel": "debug",
|
||||||
|
10
main.js
10
main.js
@ -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, {});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
Loading…
x
Reference in New Issue
Block a user