From 0374cbd4c9ca794063b5a2f21d9f57dd136e29f7 Mon Sep 17 00:00:00 2001 From: ivanm Date: Thu, 3 Oct 2024 18:20:21 +0200 Subject: [PATCH] fix: hotfix email rutas --- .../route/back/methods/route/driverRouteEmail.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/modules/route/back/methods/route/driverRouteEmail.js b/modules/route/back/methods/route/driverRouteEmail.js index 62147db87..bbac2b0e8 100644 --- a/modules/route/back/methods/route/driverRouteEmail.js +++ b/modules/route/back/methods/route/driverRouteEmail.js @@ -39,8 +39,6 @@ module.exports = Self => { const {reportMail} = agencyMode(); let user; let account; - let userEmail; - ctx.args.recipients = reportMail ? reportMail.split(',').map(email => email.trim()) : []; if (workerFk) { user = await models.VnUser.findById(workerFk, { @@ -50,17 +48,10 @@ module.exports = Self => { account = await models.Account.findById(workerFk); } - if (user?.active && account) - userEmail = user.emailUser().email; - - if (userEmail) - ctx.args.recipients.push(userEmail); - - ctx.args.recipients = [...new Set(ctx.args.recipients)]; - - if (!ctx.args.recipients.length) - throw new UserError('An email is necessary'); + if (user?.active && account) ctx.args.recipient = user.emailUser().email; + else ctx.args.recipient = reportMail; + if (!ctx.args.recipient) throw new UserError('An email is necessary'); return Self.sendTemplate(ctx, 'driver-route'); }; }; -- 2.40.1