From 809acae4b60dbf0652a8ca3e89b9b528833de3f9 Mon Sep 17 00:00:00 2001 From: Rafael Lopes Date: Tue, 16 Dec 2025 10:50:04 -0300 Subject: [PATCH] =?UTF-8?q?FIX:=20Renomear=20fun=C3=A7=C3=A3o=20handleMund?= =?UTF-8?q?ialeTicket=20para=20handleTicket=20e=20atualizar=20l=C3=B3gica?= =?UTF-8?q?=20de=20verifica=C3=A7=C3=A3o=20de=20escopo,=20permitindo=20que?= =?UTF-8?q?=20chamados=20fora=20do=20tipo=20mundiale=20sejam=20fechados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/ticketService.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/services/ticketService.js b/src/services/ticketService.js index fc1c274..c2547ce 100644 --- a/src/services/ticketService.js +++ b/src/services/ticketService.js @@ -15,10 +15,10 @@ const e = require('express'); * @returns {Promise} Um objeto com os IDs { hubsoftId, glpiId, syncId } ou null se não for aplicável. */ -const handleMundialeTicket = async (glpiTicketId, ticketTitle) => { +const handleTicket = async (glpiTicketId, ticketTitle) => { try { - if (!ticketTitle.includes("Mundiale")) { - logInfo(`Ticket ID ${glpiTicketId} não é da Mundiale. Ignorando fechamento.`); + if (!tolow(ticketTitle).includes("mundiale") || !tolow(ticketTitle).includes("implantacao") || !tolow(ticketTitle).includes("sac") || !tolow(ticketTitle).includes('cancelamento') || !tolow(ticketTitle).includes('troca de titularidade')) { + logInfo(`Ticket ID ${glpiTicketId} esta fora do escopo do fluxo. Ignorando fechamento.`); return null; } @@ -45,7 +45,7 @@ const handleMundialeTicket = async (glpiTicketId, ticketTitle) => { return null; } } catch (error) { - logError(`Erro em handleMundialeTicket para o ticket ID ${glpiTicketId}:`, error); + logError(`Erro em handleTicket para o ticket ID ${glpiTicketId}:`, error); throw error; // Propaga o erro para o chamador } }; @@ -102,7 +102,7 @@ const fechaTicket = async (bodyRequest) => { const closingMessage = sanitizeGLPIComment({ content: rawClosingMessage }); try { - const ticketInfo = await handleMundialeTicket(glpiTicketId, ticketTitle); + const ticketInfo = await handleTicket(glpiTicketId, ticketTitle); if (ticketInfo) { const closeResponse = await closeHubsoftTicket(ticketInfo.hubsoftId, closingMessage); @@ -138,7 +138,7 @@ module.exports = { fechaTicket }; * * Funções: * - `fechaTicket(bodyRequest)`: Orquestra todo o processo de fechamento. - * - `handleMundialeTicket(...)`: Verifica se o ticket é elegível para o fluxo e tenta obter uma trava no banco de dados para evitar processamento duplicado. + * - `handleTicket(...)`: Verifica se o ticket é elegível para o fluxo e tenta obter uma trava no banco de dados para evitar processamento duplicado. * - `closeHubsoftTicket(...)`: Interage com o `hubsoftService` para fechar o atendimento no HubSoft. Trata o caso onde o ticket já está fechado. * - `updateLocalDatabaseOnClose(...)`: Atualiza o status do ticket no banco de dados local após o fechamento bem-sucedido. */