fix: ajuste na validacao dos bots e pausar sessao

This commit is contained in:
Joao Vitor
2025-06-15 18:24:34 -03:00
parent a1fae85531
commit 029d68e2cd
3 changed files with 19 additions and 7 deletions

View File

@@ -1,16 +1,20 @@
import { advancedOperatorsSearch } from './advancedOperatorsSearch';
export const findBotByTrigger = async (botRepository: any, content: string, instanceId: string) => {
// 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({