Send SMS messages from correct number
This commit is contained in:
parent
261841b19f
commit
813fdbc7c2
13
main.js
13
main.js
@ -270,11 +270,11 @@ function sendMatrixNotice(roomid, body, callback) {
|
|||||||
* @param {function|undefined} callback passes true when successful, false on failure.
|
* @param {function|undefined} callback passes true when successful, false on failure.
|
||||||
* @returns {undefined}
|
* @returns {undefined}
|
||||||
*/
|
*/
|
||||||
function sendSMS(number, body, callback) {
|
function sendSMS(number, from, body, callback) {
|
||||||
logger.info("Sending SMS to " + number);
|
logger.info("Sending SMS to " + number);
|
||||||
const data = JSON.stringify({
|
const data = JSON.stringify({
|
||||||
to: [number],
|
to: [number],
|
||||||
from: settings.smsfrom,
|
from: from,
|
||||||
body: body
|
body: body
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -362,7 +362,14 @@ 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, 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, {});
|
client.sendReadReceipt(event, {});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user