diff --git a/modules/client/back/methods/client/consumptionSendQueued.js b/modules/client/back/methods/client/consumptionSendQueued.js index 31b54b21d..849e2b304 100644 --- a/modules/client/back/methods/client/consumptionSendQueued.js +++ b/modules/client/back/methods/client/consumptionSendQueued.js @@ -21,7 +21,7 @@ module.exports = Self => { id, params FROM clientConsumptionQueue - WHERE status = ''`); + WHERE status = '' OR status IS NULL`); for (const queue of queues) { try { @@ -44,16 +44,21 @@ module.exports = Self => { GROUP BY c.id`, [params.clients, params.from, params.to]); for (const client of clients) { - const args = { - id: client.clientFk, - recipient: client.clientEmail, - replyTo: client.salesPersonEmail, - from: params.from, - to: params.to - }; + try { + const args = { + id: client.clientFk, + recipient: client.clientEmail, + replyTo: client.salesPersonEmail, + from: params.from, + to: params.to + }; - const email = new Email('campaign-metrics', args); - await email.send(); + const email = new Email('campaign-metrics', args); + await email.send(); + } catch (error) { + if (error.code !== 'EENVELOPE') + throw error; + } } await Self.rawSql(`