Skip to content

Commit

Permalink
Email when notification fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Nithriel committed Nov 26, 2024
1 parent f0d452f commit 4ea91f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
11 changes: 7 additions & 4 deletions app/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,19 @@ const CONFIG = nconf
alias: 'testing:managerUsername',
},
'email.email': {
alias: 'email.email',
alias: 'email:email',
},
'email.password': {
alias: 'email.password',
alias: 'email:password',
},
'email.domain': {
alias: 'email.domain',
alias: 'email:domain',
},
'email.ehost': {
alias: 'email.ehost',
alias: 'email:ehost',
},
'email.failemail': {
alias: 'email:failemail',
},
'log.level': {
alias: 'log:level',
Expand Down
11 changes: 10 additions & 1 deletion app/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ const {graphkbGetReadonlyGroupId, graphkbAddUser} = require('./api/graphkb');
const conf = require('./config');
const createReport = require('./libs/createReport');
const db = require('./models');
const {sendEmail} = require('./libs/email');

const {host, port, enableQueue} = conf.get('redis_queue');
const logger = require('./log'); // Load logging library

const CONFIG = require('./config');

const {email, password, ehost} = CONFIG.get('email');
const {email, password, ehost, failemail} = CONFIG.get('email');

const setUpEmailQueue = () => {
if (enableQueue) {
Expand Down Expand Up @@ -127,6 +128,14 @@ const onEmailWorkderFailed = async (job) => {
logger.error(`Unable to create notification track ${error}`);
throw new Error(error);
}

try {
if (failemail) {
await sendEmail('Notification failed', job.data, failemail);
}
} catch (error) {
logger.error(`Unable to send email ${error}`);
}
};

const emailProcessor = async (job) => {
Expand Down

0 comments on commit 4ea91f4

Please sign in to comment.