#8002 adjust to Lilium #3199
|
@ -29,35 +29,32 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.sendToSupport = async(ctx, reason, additionalData) => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const emailUser =
|
||||
await Self.app.models.EmailUser.findById(ctx.req.accessToken.userId, {fields: ['email']});
|
||||
await Self.app.models.EmailUser.findById(userId, {fields: ['email']});
|
||||
const {code, message, path, request, status, statusText, config: errConfig, name} = additionalData;
|
||||
|
||||
let html = `<strong>Motivo</strong>:<br/>${reason}<br/>`;
|
||||
html += `<strong>Usuario</strong>:<br/>${ctx.req.accessToken.userId} ${emailUser.email}<br/>`;
|
||||
let html = `<h2>Motivo: ${reason}</h2>`;
|
||||
html += `<h3>Usuario: ${userId} ${emailUser.email}</h3>`;
|
||||
html += `<h3>Additional Data:</h3>`;
|
||||
html += `<ul><li>Code: ${code}</li>`;
|
||||
html += `<li>Message: ${message}</li>`;
|
||||
html += `<li>Path: ${path}</li>`;
|
||||
html += `<li>Request: ${request}</li>`;
|
||||
html += `<li>Status: ${status}</li>`;
|
||||
html += `<li>StatusText: ${statusText}</li>`;
|
||||
html += `<li>Config:</li><ul style="list-style-type: square;">`;
|
||||
for (const [key, val] of Object.entries(errConfig)) html += `<li>${key}: ${parse(val)}</li>`;
|
||||
html += '</ul></ul>';
|
||||
|
||||
delete additionalData.backError.config.headers.Authorization;
|
||||
const httpRequest = JSON.parse(additionalData?.httpRequest);
|
||||
|
||||
if (httpRequest)
|
||||
delete httpRequest.config.headers.Authorization;
|
||||
additionalData.httpRequest = httpRequest;
|
||||
|
||||
for (const data in additionalData)
|
||||
html += `<strong>${data}</strong>:<br/>${tryParse(additionalData[data])}<br/>`;
|
||||
|
||||
const subjectReason = httpRequest?.data?.error;
|
||||
await smtp.send({
|
||||
to: `${config.app.reportEmail}, ${emailUser.email}`,
|
||||
subject:
|
||||
'[Support-Salix] ' +
|
||||
additionalData?.frontPath + ' ' +
|
||||
subjectReason?.name + ':' +
|
||||
subjectReason?.message,
|
||||
subject: `[Support-Salix] ${path} ${name}: ${message}`,
|
||||
html
|
||||
});
|
||||
};
|
||||
|
||||
function tryParse(value) {
|
||||
function parse(value) {
|
||||
try {
|
||||
try {
|
||||
value = JSON.parse(value);
|
||||
|
|
Loading…
Reference in New Issue