Merge pull request 'feat: refs #8571 enhance email formatting in sendToSupport function with structured HTML table' (!3445) from 8571-hotfix-notShowToken into master
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #3445 Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
commit
e99fbca255
|
@ -33,25 +33,52 @@ module.exports = Self => {
|
||||||
const emailUser =
|
const emailUser =
|
||||||
await Self.app.models.EmailUser.findById(userId, {fields: ['email']});
|
await Self.app.models.EmailUser.findById(userId, {fields: ['email']});
|
||||||
|
|
||||||
let html = `<h2>Motivo: ${reason}</h2>`;
|
const tableStyle = 'width:100%; border-collapse: collapse; text-align: left;';
|
||||||
html += `<h3>Usuario: ${userId} ${emailUser.email}</h3>`;
|
const thStyle = 'padding: 8px; border: 1px solid #ddd; background-color: #f4f4f4;';
|
||||||
html += `<h3>Additional Data:</h3>`;
|
const tdStyle = 'padding: 8px; border: 1px solid #ddd;';
|
||||||
html += '<ul>';
|
const tdBoldStyle = 'padding: 8px; border: 1px solid #ddd; font-weight: bold;';
|
||||||
|
const subTdStyle = 'padding: 6px; border: 1px solid #ddd;';
|
||||||
|
const subTdBoldStyle = 'padding: 6px; border: 1px solid #ddd; font-weight: bold;';
|
||||||
|
|
||||||
|
let html = `
|
||||||
|
<h2>Motivo: ${reason}</h2>
|
||||||
|
<h3>Usuario: ${userId} ${emailUser.email}</h3>
|
||||||
|
<h3>Additional Data:</h3>
|
||||||
|
<table style="${tableStyle}">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style="${thStyle}">Clave</th><th style="${thStyle}">Valor</th></tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>`;
|
||||||
for (const [key, val] of Object.entries(additionalData)) {
|
for (const [key, val] of Object.entries(additionalData)) {
|
||||||
if (key !== 'config') html += `<li>${key}: ${parse(val)}</li>`;
|
if (key !== 'config') {
|
||||||
else {
|
html += `<tr>
|
||||||
html += `<li>${key}:</li><ul style="list-style-type: square;">`;
|
<td style="${tdBoldStyle}">${key}</td>
|
||||||
for (const [confKey, confVal] of Object.entries(val))
|
<td style="${tdStyle}">${parse(val)}</td>
|
||||||
html += `<li>${confKey}: ${parse(confVal)}</li>`;
|
</tr>`;
|
||||||
html += '</ul>';
|
} else {
|
||||||
|
html += `<tr>
|
||||||
|
<td style="${tdBoldStyle}">${key}</td>
|
||||||
|
<td style="${tdStyle}">
|
||||||
|
<table style="${tableStyle}">
|
||||||
|
<tbody>`;
|
||||||
|
for (const [confKey, confVal] of Object.entries(val)) {
|
||||||
|
html += `<tr>
|
||||||
|
<td style="${subTdBoldStyle}">${confKey}</td>
|
||||||
|
<td style="${subTdStyle}">${parse(confVal)}</td>
|
||||||
|
</tr>`;
|
||||||
|
}
|
||||||
|
html += `</tbody></table></td></tr>`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
html += '</ul>';
|
html += `</tbody></table>`;
|
||||||
|
|
||||||
const {message, path, name} = additionalData;
|
const {message, path, name} = additionalData;
|
||||||
|
const err = name && message ? `${name}: ${message}` : name || message || '';
|
||||||
|
|
||||||
await smtp.send({
|
await smtp.send({
|
||||||
to: `${config.app.reportEmail}, ${emailUser.email}`,
|
to: `${config.app.reportEmail}, ${emailUser.email}`,
|
||||||
subject: `[Support-Salix] ${path} ${name}: ${message}`,
|
subject: `[Support-Salix] ${path.split('?')[0]} ${err}`,
|
||||||
html
|
html
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue