From 1c49c073eebf29a7da16101f6bce11ed1eaa37ad Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 13 Nov 2024 15:45:06 +0100 Subject: [PATCH 1/5] feat: refs #8002 drop support btn --- front/core/components/snackbar/snackbar.js | 11 +---------- front/core/components/support-dialog/index.js | 12 ++++++------ 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/front/core/components/snackbar/snackbar.js b/front/core/components/snackbar/snackbar.js index b380c47c3..49d784067 100644 --- a/front/core/components/snackbar/snackbar.js +++ b/front/core/components/snackbar/snackbar.js @@ -27,17 +27,8 @@ export default class Controller extends Component { setTimeout(() => element.classList.add('shown'), 30); shape.element = element; - if (data.additionalData && this.vnToken.token) { + if (data.additionalData && this.vnToken.token) this.additionalData = data.additionalData; - 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) element.classList.add(shape.type); diff --git a/front/core/components/support-dialog/index.js b/front/core/components/support-dialog/index.js index d15c14b4a..45a8147fe 100644 --- a/front/core/components/support-dialog/index.js +++ b/front/core/components/support-dialog/index.js @@ -10,12 +10,12 @@ export default class Controller extends Dialog { if (response !== 'accept') 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!'))); + // 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!'))); } } -- 2.40.1 From b75b369716ded8737a6f32d65ec6c93e0f0c25ad Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 13 Nov 2024 17:35:27 +0100 Subject: [PATCH 2/5] 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); -- 2.40.1 From 873b91f1130beb17cc05367d8aecea310914c386 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 13 Nov 2024 17:45:15 +0100 Subject: [PATCH 3/5] chore: refs #8002 drop comments --- front/core/components/support-dialog/index.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/front/core/components/support-dialog/index.js b/front/core/components/support-dialog/index.js index 45a8147fe..82f086184 100644 --- a/front/core/components/support-dialog/index.js +++ b/front/core/components/support-dialog/index.js @@ -9,13 +9,6 @@ export default class Controller extends Dialog { responseHandler(response) { if (response !== 'accept') 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!'))); } } -- 2.40.1 From 285fe67ca5f64c4db744ace0ded4a95d1332372a Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 14 Nov 2024 10:38:44 +0100 Subject: [PATCH 4/5] chore: refs #8002 drop useless code --- front/core/components/snackbar/snackbar.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/front/core/components/snackbar/snackbar.js b/front/core/components/snackbar/snackbar.js index 49d784067..cce285d14 100644 --- a/front/core/components/snackbar/snackbar.js +++ b/front/core/components/snackbar/snackbar.js @@ -27,9 +27,6 @@ export default class Controller extends Component { setTimeout(() => element.classList.add('shown'), 30); shape.element = element; - if (data.additionalData && this.vnToken.token) - this.additionalData = data.additionalData; - if (shape.type) element.classList.add(shape.type); -- 2.40.1 From dbf5953d69f55e5f7bb866318fd01aff6de2a98b Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 14 Nov 2024 10:47:39 +0100 Subject: [PATCH 5/5] refactor: refs #8002 use loop wip --- back/methods/osticket/sendToSupport.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/back/methods/osticket/sendToSupport.js b/back/methods/osticket/sendToSupport.js index d05f1a82e..dabd35f80 100644 --- a/back/methods/osticket/sendToSupport.js +++ b/back/methods/osticket/sendToSupport.js @@ -32,21 +32,23 @@ module.exports = Self => { const userId = ctx.req.accessToken.userId; const emailUser = 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: ${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 += '
'; + html += '
    '; + for (const [key, val] of Object.entries(additionalData)) { + if (key !== 'config') html += `
  • ${key}: ${parse(val)}
  • `; + else { + html += `
  • ${key}:
    • `; + for (const [confKey, confVal] of Object.entries(val)) + html += `
    • ${confKey}: ${parse(confVal)}
    • `; + html += '
    '; + } + } + html += '
'; + const {message, path, name} = additionalData; await smtp.send({ to: `${config.app.reportEmail}, ${emailUser.email}`, subject: `[Support-Salix] ${path} ${name}: ${message}`, -- 2.40.1