mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-02-12 11:01:52 +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': {
|
||||
// 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 (!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('{{phone}}') == -1) { console.log('Invalid or missing SMS gateway, URL must include {{phone}}.'); return null; }
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
@ -132,6 +134,11 @@ module.exports.CreateMeshSMS = function (parent) {
|
|||
if (func != null) { func((err == null), err ? err.type : null, result); }
|
||||
});
|
||||
} 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));
|
||||
parent.debug('email', 'SMS URL: ' + sms);
|
||||
sms = require('url').parse(sms);
|
||||
|
@ -150,6 +157,7 @@ module.exports.CreateMeshSMS = function (parent) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get the correct SMS template
|
||||
function getTemplate(templateNumber, domain, lang) {
|
||||
|
|
Loading…
Reference in a new issue