refs #5941 fix(sendToSupport): fix email from
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2023-08-21 13:48:51 +02:00
parent 6d60592fb9
commit 36623c1cae
2 changed files with 6 additions and 2 deletions

View File

@ -33,6 +33,7 @@ module.exports = Self => {
await Self.app.models.EmailUser.findById(ctx.req.accessToken.userId, {fields: ['email']}); await Self.app.models.EmailUser.findById(ctx.req.accessToken.userId, {fields: ['email']});
let html = `<strong>Motivo</strong>:<br/>${reason}<br/>`; let html = `<strong>Motivo</strong>:<br/>${reason}<br/>`;
html += `<strong>Usuario</strong>:<br/>${ctx.req.accessToken.userId} ${emailUser.email}<br/>`;
for (const data in additionalData) for (const data in additionalData)
html += `<strong>${data}</strong>:<br/>${tryParse(additionalData[data])}<br/>`; html += `<strong>${data}</strong>:<br/>${tryParse(additionalData[data])}<br/>`;
@ -40,6 +41,7 @@ module.exports = Self => {
const subjectReason = JSON.parse(additionalData?.httpRequest)?.data?.error; const subjectReason = JSON.parse(additionalData?.httpRequest)?.data?.error;
smtp.send({ smtp.send({
to: config.app.reportEmail, to: config.app.reportEmail,
from: emailUser.email,
replyTo: emailUser.email, replyTo: emailUser.email,
subject: subject:
'[Support-Salix] ' + '[Support-Salix] ' +

View File

@ -9,7 +9,7 @@ module.exports = {
}, },
async send(options) { async send(options) {
options.from = `${config.app.senderName} <${config.app.senderEmail}>`; options.from = options.from ?? `${config.app.senderName} <${config.app.senderEmail}>`;
const env = process.env.NODE_ENV; const env = process.env.NODE_ENV;
const canSend = env === 'production' || !env || options.force; const canSend = env === 'production' || !env || options.force;
@ -19,8 +19,10 @@ module.exports = {
return Promise.resolve(true); return Promise.resolve(true);
} }
if (!env) if (!env) {
options.to = config.app.senderEmail; options.to = config.app.senderEmail;
options.from = `${config.app.senderName} <${config.app.senderEmail}>`;
}
let res; let res;
let error; let error;