feat: refs #7343 Modify driverRouteEmail.js
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
9efc712859
commit
c30ecd3760
|
@ -39,6 +39,8 @@ module.exports = Self => {
|
||||||
const {reportMail} = agencyMode();
|
const {reportMail} = agencyMode();
|
||||||
let user;
|
let user;
|
||||||
let account;
|
let account;
|
||||||
|
let userEmail = null;
|
||||||
|
let reportEmails = 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,22 @@ 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 (!ctx.args.recipient) throw new UserError('An email is necessary');
|
let recipients = reportEmails;
|
||||||
|
if (userEmail) {
|
||||||
|
recipients.push(userEmail);
|
||||||
|
}
|
||||||
|
|
||||||
|
recipients = [...new Set(recipients)];
|
||||||
|
|
||||||
|
if (recipients.length === 0) {
|
||||||
|
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