Skip to content

Commit

Permalink
Merge branch 'master' into update-smpp-node-dep
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroVega authored Sep 20, 2024
2 parents da68d77 + 1cf840d commit 7458025
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 42 deletions.
2 changes: 1 addition & 1 deletion CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Upgrade smpp dep from 0.3.1 to 0.5.1
- Upgrade smpp dep from 0.3.1 to 0.5.1
15 changes: 15 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
1.34.0 (July 30th, 2024)

- Fix: smtpConfig after error in emailAction rule (#798)

1.33.0 (July 29th, 2024)

- Fix: do not search in entities collection with strict mode by non_signal checker (#793)
- Fix: do not try cast entity id and entity type in update rules when expand parameters of rule to avoid BadRequest en CB tries to update that entities (#791)
- Fix: do not invoke calback twice when error about trust not found in trustConf (#790)

1.32.0 (June 13th, 2024)

- Add: Send multiple sms when multiple destination in sms action
- Fix: upgrade rule in mongo using service and subservice to avoid match with other rule (#783)

1.31.0 (June 11th, 2024)

- Fix: release transport resources of nodemailer after send email
Expand Down
7 changes: 4 additions & 3 deletions lib/models/emailAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ function SendMail(action, event, callback) {
smtpConfig = config.smtp;
msgFromConfig = 'from global';
}
var smtpAuth = smtpConfig.auth;
smtpConfig.auth = { user: 'UUU', pass: 'XXX' };
var smtpAuth = smtpConfig.auth ? Object.assign({}, smtpConfig.auth) : undefined; // force clone
smtpConfig.auth = { user: 'UUU', pass: 'XXX' }; // fake auth for log purposes
logger.debug('Using smtp transporter %j config: %j', msgFromConfig, smtpConfig);
smtpConfig.auth = smtpAuth;
smtpConfig.auth = smtpAuth; // restore auth
transporter = nodemailer.createTransport(smtpTransport(smtpConfig));
metrics.IncMetrics(event.service, event.subservice, metrics.actionEmail);

Expand All @@ -105,6 +105,7 @@ function SendMail(action, event, callback) {
};
opt2log.smtp.auth = { user: 'UUU', pass: 'XXX' };
myutils.logErrorIf(err, util.format('emailAction.SendMail %j', opt2log));
smtpConfig.auth = smtpAuth; // ensure smtpConfig.auth is not tainted
alarm.raise(alarm.EMAIL);
} else {
metrics.IncMetrics(event.service, event.subservice, metrics.okActionEmail);
Expand Down
2 changes: 1 addition & 1 deletion lib/models/entitiesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function findSilentEntitiesByMongo(service, subservice, ruleData, alterFunc, cal

async.waterfall(
[
db.collection.bind(db, entitiesCollectionName, { strict: true }),
db.collection.bind(db, entitiesCollectionName, { strict: false }),
function(col, cb) {
col.find(criterion)
.batchSize(config.orionDb.batchSize)
Expand Down
4 changes: 2 additions & 2 deletions lib/models/keystone.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ function getToken(trust, callback) {

// check trust was found or log it
if (!trustConf) {
logger.error('Trust %s not found in configTrust file with content %s', trust, configTrust);
callback(new errors.TokenRetrievalError(trust, 'trust not found' + trust));
logger.error('Trust %s not found in configTrust file', trust);
throw errors.TokenRetrievalError(trust, 'trust not found' + trust);
}
var options = {
url: 'http://' + trustConf.host + ':' + trustConf.port + '/v3/auth/tokens',
Expand Down
6 changes: 5 additions & 1 deletion lib/models/rulesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ module.exports = {
db.collection.bind(db, rulesCollectionName, { strict: true }),
function(col, cb) {
col.findOneAndUpdate(
{ name: id },
{
name: id,
service: r.service,
subservice: r.subservice
},
{ $set: r },
{
upsert: false,
Expand Down
60 changes: 32 additions & 28 deletions lib/models/smsAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ function doIt(action, event, callback) {
if (options.sms && options.sms.from) {
from = options.sms.from;
}
msg = { to: buildTo(options.to), message: options.text, from: from };

metrics.IncMetrics(event.service, event.subservice, metrics.actionSMS);

var url = config.sms.URL;
var apiKey = config.sms.API_KEY;
var apiSecret = config.sms.API_SECRET;
Expand All @@ -89,33 +85,41 @@ function doIt(action, event, callback) {
apiSecret = options.sms.API_SECRET;
}
}
myutils.requestHelper(
'post',
{
url: url,
json: true,
body: msg,
headers: {
'User-Agent': 'request',
API_KEY: apiKey,
API_SECRET: apiSecret
}
},
function(err, data) {
myutils.logErrorIf(err, util.format('%s -> %s', url, msg.to));
if (err) {
metrics.IncMetrics(event.service, event.subservice, metrics.failedActionSMS);
metrics.IncMetrics(event.service, event.subservice, metrics.actionSMS);

alarm.raise(alarm.SMS);
} else {
metrics.IncMetrics(event.service, event.subservice, metrics.okActionSMS);
var tos = buildTo(options.to);

alarm.release(alarm.SMS);
for (var singleto of tos) {
msg = { to: [singleto], message: options.text, from: config.sms.from };
myutils.requestHelper(
'post',
{
url: url,
json: true,
body: msg,
headers: {
'User-Agent': 'request',
API_KEY: apiKey,
API_SECRET: apiSecret
}
},
function(err, data) { // jshint ignore:line
myutils.logErrorIf(err, util.format('%s -> %s', url, msg.to));
if (err) {
metrics.IncMetrics(event.service, event.subservice, metrics.failedActionSMS);
alarm.raise(alarm.SMS);
} else {
metrics.IncMetrics(event.service, event.subservice, metrics.okActionSMS);
alarm.release(alarm.SMS);
}
logger.info('smsAction.SendSMS done url:%s result:%j, msg: %j', url, err || data, msg);
if (tos[tos.length - 1] === singleto) {
// ensure callback is returned just one time
return callback(err, data);
}
}
logger.info('smsAction.SendSMS done url:%s result:%j, msg: %j', url, err || data, msg);
return callback(err, data);
}
);
);
}
} catch (ex) {
metrics.IncMetrics(event.service, event.subservice, metrics.failedActionSMS);

Expand Down
7 changes: 4 additions & 3 deletions lib/models/updateAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,9 @@ function processOptionParams(action, event) {
changes[key].metadata = theMeta;
}
});
changes.id = myutils.expandVar(action.parameters.id, event, true);
changes.type = myutils.expandVar(action.parameters.type, event, true);
// Do not expandVar with trycast, since entity id and type should be always string values types
changes.id = myutils.expandVar(action.parameters.id, event, false);
changes.type = myutils.expandVar(action.parameters.type, event, false);
logger.debug('processOptionParams changes: %j', changes);
return changes;
}
Expand Down Expand Up @@ -477,7 +478,7 @@ function makeTokenListenerFunc(action, event, version, callback) {
if (error || !token) {
return callback(error);
} else {
logger.debug('tokenHandlerFunc retrying with', token);
logger.debug('tokenHandlerFunc retrying with %s', token);
return doRequestV2(action, event, token, function cbDoReqUpdAxn(error, data) {
callback(error, data);
});
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "perseo",
"description": "IOT CEP front End",
"license": "AGPL-3.0-only",
"version": "1.31.0-next",
"version": "1.34.0-next",
"author": {
"name": "crbrox",
"email": "[email protected]"
Expand Down Expand Up @@ -60,8 +60,8 @@
"keywords": [],
"dependencies": {
"async": "2.6.4",
"body-parser": "~1.18.2",
"express": "4.19.2",
"body-parser": "~1.20.3",
"express": "4.20.0",
"logops": "2.1.2",
"mongodb": "3.6.12",
"ngsijs": "1.4.1",
Expand Down

0 comments on commit 7458025

Please sign in to comment.