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 += `- Code: ${code}
`;
+ html += `- Message: ${message}
`;
+ html += `- Path: ${path}
`;
+ html += `- Request: ${request}
`;
+ html += `- Status: ${status}
`;
+ html += `- StatusText: ${statusText}
`;
+ html += `- Config:
`;
+ for (const [key, val] of Object.entries(errConfig)) html += `- ${key}: ${parse(val)}
`;
+ 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);