From aabc4ec58d8690cdd67a85c9c0a7d378121755c7 Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 18 Apr 2023 10:08:04 +0200 Subject: [PATCH] fix(consumption): continue queue if client mailing fails --- .../methods/client/consumptionSendQueued.js | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) 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(`