diff --git a/t6console.js b/t6console.js index 96a4a74d..59e8f41d 100644 --- a/t6console.js +++ b/t6console.js @@ -45,19 +45,19 @@ t6console.critical = function(...criticalmessage) { if ( logAuditOnError ) { t6events.addAudit("t6App", `t6console.critical: ${criticalmessage}`, "", "", {"status": "500", error_id: "00001"}); } - var envelope = { - from: from, - bcc: bcc, - to: bcc, - user_id: bcc, - subject: `Critical Error on t6 ${app.get("env")}`, - text: `${criticalmessage}`, - html: `${criticalmessage}` - }; - if ( sendMailOnCriticalError ) { + if ( sendMailOnCriticalError && criticalmessage ) { + var envelope = { + from: from, + bcc: bcc, + to: bcc, + user_id: bcc, + subject: `Critical Error on t6 ${app.get("env")}`, + text: `${criticalmessage}`, + html: `${criticalmessage}` + }; t6mailer.sendMail(envelope); } - if ( sendTextMessageOnCriticalError ) { + if ( sendTextMessageOnCriticalError && twilioSettings.accountSid && twilioSettings.authToken && event.params.to) { const clientTwilio = new twilio(twilioSettings.accountSid, twilioSettings.authToken); clientTwilio.messages .create({ diff --git a/t6decisionrules.js b/t6decisionrules.js index f1119a03..0ce9f2cc 100644 --- a/t6decisionrules.js +++ b/t6decisionrules.js @@ -409,7 +409,7 @@ t6decisionrules.checkRulesFromUser = function(user_id, payload) { t6console.debug("pushSubscription is now disabled on User", error); } } else { - t6console.error("No user or no pushSubscription found, can't sendPush"); + t6console.error("No user or no pushSubscription found, can't sendPesh"); } } else { t6console.warn(`No matching EventType: ${event.type}`); @@ -418,19 +418,9 @@ t6decisionrules.checkRulesFromUser = function(user_id, payload) { }); engine.run(payload); }).catch((err) => { - var envelope = { - from: from, - to: bcc, - user_id: payload.user_id?payload.user_id:to, - subject: "dbInfluxDB ERR on decisionRule (checkRulesFromUser)", - text: "Html email client is required", - html: err - }; - t6console.error("dbInfluxDB ERR on decisionRule (checkRulesFromUser)", err); + t6console.critical("dbInfluxDB ERR on decisionRule (checkRulesFromUser)", err); t6console.debug("ERR on decisionRule (checkRulesFromUser) :"); t6console.debug("payload", payload); - t6console.debug("envelope", envelope); - t6mailer.sendMail(envelope); }); }; // t6decisionrules.checkRulesFromUser