fix(smtp): log attachment files sent through email
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2021-11-16 11:00:48 +01:00
parent 7894b32163
commit b7e58aa9cd
1 changed files with 13 additions and 2 deletions

View File

@ -24,13 +24,24 @@ module.exports = {
throw err;
}).finally(async() => {
const attachments = [];
for (let attachment of options.attachments) {
const fileName = attachment.filename;
const filePath = attachment.path;
// if (fileName.includes('.png')) return;
if (fileName || filePath)
attachments.push(filePath ? filePath : fileName);
}
const fileNames = attachments.join(',\n');
await db.rawSql(`
INSERT INTO vn.mail (receiver, replyTo, sent, subject, body, status)
VALUES (?, ?, 1, ?, ?, ?)`, [
INSERT INTO vn.mail (receiver, replyTo, sent, subject, body, attachment, status)
VALUES (?, ?, 1, ?, ?, ?, ?)`, [
options.to,
options.replyTo,
options.subject,
options.text || options.html,
fileNames,
error && error.message || 'Sent'
]);
});