Fix for SMS custom handler code (#4478)

This commit is contained in:
Ylian Saint-Hilaire 2022-09-02 00:47:00 -07:00
parent 49e04bd454
commit 55f56a1145
1 changed files with 2 additions and 2 deletions

View File

@ -138,13 +138,13 @@ module.exports.CreateMeshSMS = function (parent) {
if (sms.protocol == 'https:') { if (sms.protocol == 'https:') {
// HTTPS GET request // HTTPS GET request
const options = { hostname: sms.hostname, port: sms.port ? sms.port : 443, path: sms.path, method: 'GET', rejectUnauthorized: false }; const options = { hostname: sms.hostname, port: sms.port ? sms.port : 443, path: sms.path, method: 'GET', rejectUnauthorized: false };
const request = require('https').request(options, function (res) { parent.debug('email', 'SMS result: ' + res.statusCode); func(res.statusCode == 200, (res.statusCode == 200) ? null : res.statusCode, null); res.on('data', function (d) { }); }); const request = require('https').request(options, function (res) { parent.debug('email', 'SMS result: ' + res.statusCode); if (func != null) { func(res.statusCode == 200, (res.statusCode == 200) ? null : res.statusCode, null); } res.on('data', function (d) { }); });
request.on('error', function (err) { parent.debug('email', 'SMS error: ' + err); if (func != null) { func(false, err, null); } }); request.on('error', function (err) { parent.debug('email', 'SMS error: ' + err); if (func != null) { func(false, err, null); } });
request.end(); request.end();
} else { } else {
// HTTP GET request // HTTP GET request
const options = { hostname: sms.hostname, port: sms.port ? sms.port : 80, path: sms.path, method: 'GET' }; const options = { hostname: sms.hostname, port: sms.port ? sms.port : 80, path: sms.path, method: 'GET' };
const request = require('http').request(options, function (res) { parent.debug('email', 'SMS result: ' + res.statusCode); func(res.statusCode == 200, (res.statusCode == 200) ? null : res.statusCode, null); res.on('data', function (d) { }); }); const request = require('http').request(options, function (res) { parent.debug('email', 'SMS result: ' + res.statusCode); if (func != null) { func(res.statusCode == 200, (res.statusCode == 200) ? null : res.statusCode, null); } res.on('data', function (d) { }); });
request.on('error', function (err) { parent.debug('email', 'SMS error: ' + err); if (func != null) { func(false, err, null); } }); request.on('error', function (err) { parent.debug('email', 'SMS error: ' + err); if (func != null) { func(false, err, null); } });
request.end(); request.end();
} }