fix: hotfix email rutas
gitea/salix/pipeline/pr-master This commit looks good Details

This commit is contained in:
Ivan Mas 2024-10-03 18:20:21 +02:00
parent c683925403
commit 0374cbd4c9
1 changed files with 3 additions and 12 deletions

View File

@ -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');
};
};