Merge branch 'dev' into 3569-refactor_isEditable-canEdit
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
53fb575fc0
|
@ -40,19 +40,40 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.invoiceEmail = async ctx => {
|
||||
Self.invoiceEmail = async(ctx, reference) => {
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const {InvoiceOut} = Self.app.models;
|
||||
const params = {
|
||||
recipient: args.recipient,
|
||||
lang: ctx.req.getLocale()
|
||||
};
|
||||
|
||||
const invoiceOut = await InvoiceOut.findOne({
|
||||
where: {
|
||||
ref: reference
|
||||
}
|
||||
});
|
||||
|
||||
delete args.ctx;
|
||||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
const email = new Email('invoice', params);
|
||||
|
||||
return email.send();
|
||||
const [stream, ...headers] = await Self.download(ctx, invoiceOut.id);
|
||||
const name = headers[1];
|
||||
const fileName = name.replace(/filename="(.*)"/gm, '$1');
|
||||
|
||||
const mailOptions = {
|
||||
overrideAttachments: true,
|
||||
attachments: [
|
||||
{
|
||||
filename: fileName,
|
||||
content: stream
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
return email.send(mailOptions);
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue