From b75b369716ded8737a6f32d65ec6c93e0f0c25ad Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 13 Nov 2024 17:35:27 +0100 Subject: [PATCH] feat: refs #8002 adjust to lilium --- back/methods/osticket/sendToSupport.js | 37 ++++++++++++-------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/back/methods/osticket/sendToSupport.js b/back/methods/osticket/sendToSupport.js index e17093839..d05f1a82e 100644 --- a/back/methods/osticket/sendToSupport.js +++ b/back/methods/osticket/sendToSupport.js @@ -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 = `Motivo:
${reason}
`; - html += `Usuario:
${ctx.req.accessToken.userId} ${emailUser.email}
`; + let html = `

Motivo: ${reason}

`; + html += `

Usuario: ${userId} ${emailUser.email}

`; + html += `

Additional Data:

`; + html += `'; - 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 += `${data}:
${tryParse(additionalData[data])}
`; - - 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);