Send SMS messages from correct number

This commit is contained in:
Skylar Ittner 2021-06-16 15:35:51 -06:00
parent 261841b19f
commit 813fdbc7c2

13
main.js
View File

@ -270,11 +270,11 @@ function sendMatrixNotice(roomid, body, callback) {
* @param {function|undefined} callback passes true when successful, false on failure.
* @returns {undefined}
*/
function sendSMS(number, body, callback) {
function sendSMS(number, from, body, callback) {
logger.info("Sending SMS to " + number);
const data = JSON.stringify({
to: [number],
from: settings.smsfrom,
from: from,
body: body
});
@ -362,7 +362,14 @@ 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, function () {
sendSMS(tel, settings.smsfrom, sevent.getContent().body, function () {
client.sendReadReceipt(event, {});
});
} else if (matches.length == 2) {
var tel = matches[0];
var from = matches[1];
logger.info("Got message for " + tel + " from " + event.getSender() + ", relaying to " + from + ".");
sendSMS(tel, from, event.getContent().body, function () {
client.sendReadReceipt(event, {});
});
}