mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
Added SMS debug.
This commit is contained in:
parent
2eb8cbf2d6
commit
2045ebc110
1 changed files with 26 additions and 18 deletions
|
@ -80,10 +80,12 @@ module.exports.CreateMeshSMS = function (parent) {
|
||||||
}
|
}
|
||||||
case 'url': {
|
case 'url': {
|
||||||
// Validate URL configuration values
|
// Validate URL configuration values
|
||||||
|
if (parent.config.sms.url != 'console') {
|
||||||
if (typeof parent.config.sms.url != 'string') { console.log('Invalid or missing SMS gateway URL value.'); return null; }
|
if (typeof parent.config.sms.url != 'string') { console.log('Invalid or missing SMS gateway URL value.'); return null; }
|
||||||
if (!parent.config.sms.url.toLowerCase().startsWith('http://') && !parent.config.sms.url.toLowerCase().startsWith('https://')) { console.log('Invalid or missing SMS gateway, URL must start with http:// or https://.'); return null; }
|
if (!parent.config.sms.url.toLowerCase().startsWith('http://') && !parent.config.sms.url.toLowerCase().startsWith('https://')) { console.log('Invalid or missing SMS gateway, URL must start with http:// or https://.'); return null; }
|
||||||
if (parent.config.sms.url.indexOf('{{message}}') == -1) { console.log('Invalid or missing SMS gateway, URL must include {{message}}.'); return null; }
|
if (parent.config.sms.url.indexOf('{{message}}') == -1) { console.log('Invalid or missing SMS gateway, URL must include {{message}}.'); return null; }
|
||||||
if (parent.config.sms.url.indexOf('{{phone}}') == -1) { console.log('Invalid or missing SMS gateway, URL must include {{phone}}.'); return null; }
|
if (parent.config.sms.url.indexOf('{{phone}}') == -1) { console.log('Invalid or missing SMS gateway, URL must include {{phone}}.'); return null; }
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
@ -132,6 +134,11 @@ module.exports.CreateMeshSMS = function (parent) {
|
||||||
if (func != null) { func((err == null), err ? err.type : null, result); }
|
if (func != null) { func((err == null), err ? err.type : null, result); }
|
||||||
});
|
});
|
||||||
} else if (parent.config.sms.provider == 'url') { // URL
|
} else if (parent.config.sms.provider == 'url') { // URL
|
||||||
|
if (parent.config.sms.url == 'console') {
|
||||||
|
// This is for debugging, just display the SMS to the console
|
||||||
|
console.log('SMS (' + to + '): ' + msg);
|
||||||
|
if (func != null) { func(true, null, null); }
|
||||||
|
} else {
|
||||||
var sms = parent.config.sms.url.split('{{phone}}').join(encodeURIComponent(to)).split('{{message}}').join(encodeURIComponent(msg));
|
var sms = parent.config.sms.url.split('{{phone}}').join(encodeURIComponent(to)).split('{{message}}').join(encodeURIComponent(msg));
|
||||||
parent.debug('email', 'SMS URL: ' + sms);
|
parent.debug('email', 'SMS URL: ' + sms);
|
||||||
sms = require('url').parse(sms);
|
sms = require('url').parse(sms);
|
||||||
|
@ -150,6 +157,7 @@ module.exports.CreateMeshSMS = function (parent) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get the correct SMS template
|
// Get the correct SMS template
|
||||||
function getTemplate(templateNumber, domain, lang) {
|
function getTemplate(templateNumber, domain, lang) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue