From 029d68e2cdaa6b0fcc8ba28f3e15887ed606dbc1 Mon Sep 17 00:00:00 2001 From: Joao Vitor Date: Sun, 15 Jun 2025 18:24:34 -0300 Subject: [PATCH] fix: ajuste na validacao dos bots e pausar sessao --- .../chatbot/base-chatbot.controller.ts | 6 ++++++ .../integrations/chatbot/chatbot.controller.ts | 4 ++-- src/utils/findBotByTrigger.ts | 16 +++++++++++----- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/api/integrations/chatbot/base-chatbot.controller.ts b/src/api/integrations/chatbot/base-chatbot.controller.ts index 05a45beb..3a472cd8 100644 --- a/src/api/integrations/chatbot/base-chatbot.controller.ts +++ b/src/api/integrations/chatbot/base-chatbot.controller.ts @@ -880,6 +880,12 @@ export abstract class BaseChatbotController { - // Check for triggerType 'all' - const findTriggerAll = await botRepository.findFirst({ + // Check for triggerType 'all' or 'none' (both should match any message) + const findTriggerAllOrNone = await botRepository.findFirst({ where: { enabled: true, - triggerType: 'all', + triggerType: { + in: ['all', 'none'], + }, instanceId: instanceId, }, }); - if (findTriggerAll) return findTriggerAll; + if (findTriggerAllOrNone) { + return findTriggerAllOrNone; + } const findTriggerAdvanced = await botRepository.findMany({ where: { @@ -36,7 +40,9 @@ export const findBotByTrigger = async (botRepository: any, content: string, inst }, }); - if (findTriggerEquals) return findTriggerEquals; + if (findTriggerEquals) { + return findTriggerEquals; + } // Check for regex match const findRegex = await botRepository.findMany({