Merge pull request #1599 from splusoficial/develop

fix: ajuste na validacao dos bots e pausar sessao
This commit is contained in:
Davidson Gomes 2025-06-17 08:52:47 -03:00 committed by GitHub
commit 07cccb7c7f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 7 deletions

View File

@ -880,6 +880,12 @@ export abstract class BaseChatbotController<BotType = any, BotData extends BaseC
return;
}
// Skip if session exists and status is paused
if (session && session.status === 'paused') {
this.logger.warn(`Session for ${remoteJid} is paused, skipping message processing`);
return;
}
// Merged settings
const mergedSettings = {
...settings,

View File

@ -194,13 +194,13 @@ export class ChatbotController {
instance: InstanceDto,
session?: IntegrationSession,
) {
let findBot: null;
let findBot: any = null;
if (!session) {
findBot = await findBotByTrigger(botRepository, content, instance.instanceId);
if (!findBot) {
return;
return null;
}
} else {
findBot = await botRepository.findFirst({

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({