#8002 adjust to Lilium #3199

Open
jorgep wants to merge 8 commits from 8002-refactorToLilium into dev
3 changed files with 19 additions and 39 deletions

View File

@ -29,35 +29,34 @@ module.exports = Self => {
}); });
Self.sendToSupport = async(ctx, reason, additionalData) => { Self.sendToSupport = async(ctx, reason, additionalData) => {
const userId = ctx.req.accessToken.userId;
const emailUser = const emailUser =
await Self.app.models.EmailUser.findById(ctx.req.accessToken.userId, {fields: ['email']}); await Self.app.models.EmailUser.findById(userId, {fields: ['email']});
let html = `<strong>Motivo</strong>:<br/>${reason}<br/>`; let html = `<h2>Motivo: ${reason}</h2>`;
html += `<strong>Usuario</strong>:<br/>${ctx.req.accessToken.userId} ${emailUser.email}<br/>`; html += `<h3>Usuario: ${userId} ${emailUser.email}</h3>`;
html += `<h3>Additional Data:</h3>`;
html += '<ul>';
for (const [key, val] of Object.entries(additionalData)) {
jorgep marked this conversation as resolved Outdated
Outdated
Review

no seria millor fer un for in de les keys de additionalData aixina no cal ficarles a ma?

no seria millor fer un for in de les keys de additionalData aixina no cal ficarles a ma?
if (key !== 'config') html += `<li>${key}: ${parse(val)}</li>`;
else {
html += `<li>${key}:</li><ul style="list-style-type: square;">`;
for (const [confKey, confVal] of Object.entries(val))
html += `<li>${confKey}: ${parse(confVal)}</li>`;
html += '</ul>';
}
}
html += '</ul>';
delete additionalData.backError.config.headers.Authorization; const {message, path, name} = additionalData;
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({ await smtp.send({
to: `${config.app.reportEmail}, ${emailUser.email}`, to: `${config.app.reportEmail}, ${emailUser.email}`,
subject: subject: `[Support-Salix] ${path} ${name}: ${message}`,
'[Support-Salix] ' +
additionalData?.frontPath + ' ' +
subjectReason?.name + ':' +
subjectReason?.message,
html html
}); });
}; };
function tryParse(value) { function parse(value) {
try { try {
try { try {
value = JSON.parse(value); value = JSON.parse(value);

View File

@ -27,18 +27,6 @@ export default class Controller extends Component {
setTimeout(() => element.classList.add('shown'), 30); setTimeout(() => element.classList.add('shown'), 30);
shape.element = element; shape.element = element;
if (data.additionalData && this.vnToken.token) {
this.additionalData = data.additionalData;
jorgep marked this conversation as resolved Outdated
Outdated
Review

Esto ya no hcae falta tampococ no?

Esto ya no hcae falta tampococ no?
let supportButton = document.createElement('i');
supportButton.setAttribute('class', 'material-icons clickable');
supportButton.addEventListener('click', () => this.$.supportDialog.show());
element.appendChild(supportButton);
let buttonIcon = 'support_agent';
buttonIcon = document.createTextNode(buttonIcon);
supportButton.appendChild(buttonIcon);
}
if (shape.type) if (shape.type)
element.classList.add(shape.type); element.classList.add(shape.type);

View File

@ -9,13 +9,6 @@ export default class Controller extends Dialog {
responseHandler(response) { responseHandler(response) {
if (response !== 'accept') if (response !== 'accept')
return super.responseHandler(response); return super.responseHandler(response);
this.$http.post('Ostickets/send-to-support', {
reason: this.reason,
additionalData: this.additionalData
})
.then(() => super.responseHandler(response))
.then(() => this.vnApp.showSuccess(this.$t('Email sended!')));
} }
} }