Merge pull request 'feat: refs #7343 Modify driverRouteEmail.js' (!2994) from 7343-ModifyDiverRouteEmail into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #2994 Reviewed-by: Guillermo Bonet <guillermo@verdnatura.es>
This commit is contained in:
commit
5dec25d423
|
@ -39,6 +39,8 @@ module.exports = Self => {
|
||||||
const {reportMail} = agencyMode();
|
const {reportMail} = agencyMode();
|
||||||
let user;
|
let user;
|
||||||
let account;
|
let account;
|
||||||
|
let userEmail;
|
||||||
|
ctx.args.recipients = reportMail ? reportMail.split(',').map(email => email.trim()) : [];
|
||||||
|
|
||||||
if (workerFk) {
|
if (workerFk) {
|
||||||
user = await models.VnUser.findById(workerFk, {
|
user = await models.VnUser.findById(workerFk, {
|
||||||
|
@ -48,10 +50,17 @@ module.exports = Self => {
|
||||||
account = await models.Account.findById(workerFk);
|
account = await models.Account.findById(workerFk);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user?.active && account) ctx.args.recipient = user.emailUser().email;
|
if (user?.active && account)
|
||||||
else ctx.args.recipient = reportMail;
|
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 (!ctx.args.recipient) throw new UserError('An email is necessary');
|
|
||||||
return Self.sendTemplate(ctx, 'driver-route');
|
return Self.sendTemplate(ctx, 'driver-route');
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue