8032-devToTest_2440 #3009
|
@ -39,8 +39,8 @@ module.exports = Self => {
|
||||||
const {reportMail} = agencyMode();
|
const {reportMail} = agencyMode();
|
||||||
let user;
|
let user;
|
||||||
let account;
|
let account;
|
||||||
let userEmail = null;
|
let userEmail;
|
||||||
let reportEmails = reportMail ? reportMail.split(',').map(email => email.trim()) : [];
|
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, {
|
||||||
|
@ -50,22 +50,17 @@ module.exports = Self => {
|
||||||
account = await models.Account.findById(workerFk);
|
account = await models.Account.findById(workerFk);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user?.active && account) {
|
if (user?.active && account)
|
||||||
userEmail = user.emailUser().email;
|
userEmail = user.emailUser().email;
|
||||||
}
|
|
||||||
|
|
||||||
let recipients = reportEmails;
|
if (userEmail)
|
||||||
if (userEmail) {
|
ctx.args.recipients.push(userEmail);
|
||||||
recipients.push(userEmail);
|
|
||||||
}
|
|
||||||
|
|
||||||
recipients = [...new Set(recipients)];
|
ctx.args.recipients = [...new Set(ctx.args.recipients)];
|
||||||
|
|
||||||
if (recipients.length === 0) {
|
if (!ctx.args.recipients.length)
|
||||||
throw new UserError('An email is necessary');
|
throw new UserError('An email is necessary');
|
||||||
}
|
|
||||||
|
|
||||||
ctx.args.recipients = recipients;
|
|
||||||
return Self.sendTemplate(ctx, 'driver-route');
|
return Self.sendTemplate(ctx, 'driver-route');
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue