Add develop debug branch

This commit is contained in:
Saulo Mendes Martins 2025-08-21 07:45:23 -03:00
parent 2786f17008
commit 7632ee7f99
3 changed files with 50 additions and 14 deletions

View File

@ -22,7 +22,10 @@ export class BaileysMessageProcessor {
this.subscription = this.messageSubject this.subscription = this.messageSubject
.pipe( .pipe(
tap(({ messages }) => { tap(({ messages }) => {
this.processorLogs.log(`Processing batch of ${messages.length} messages`); this.processorLogs.log(`🚀 [BaileysMessageProcessor] Processing batch of ${messages.length} messages`);
messages.forEach((msg, index) => {
this.processorLogs.log(`📱 [BaileysMessageProcessor] Message ${index + 1}: ${msg.key?.remoteJid} - ${msg.message?.conversation || msg.message?.extendedTextMessage?.text || 'NO_TEXT'}`);
});
}), }),
concatMap(({ messages, type, requestId, settings }) => concatMap(({ messages, type, requestId, settings }) =>
from(onMessageReceive({ messages, type, requestId }, settings)).pipe( from(onMessageReceive({ messages, type, requestId }, settings)).pipe(

View File

@ -1047,7 +1047,10 @@ export class BaileysStartupService extends ChannelStartupService {
settings: any, settings: any,
) => { ) => {
try { try {
this.logger.log(`🚀 [Baileys] MESSAGES.UPSERT STARTED - type: ${type}, messages: ${messages.length}`);
for (const received of messages) { for (const received of messages) {
this.logger.log(`📱 [Baileys] Processing message: ${received.key.id} from ${received.key.remoteJid} - text: "${received.message?.conversation || received.message?.extendedTextMessage?.text || 'NO_TEXT'}"`);
if (received.key.remoteJid?.includes('@lid') && received.key.senderPn) { if (received.key.remoteJid?.includes('@lid') && received.key.senderPn) {
(received.key as { previousRemoteJid?: string | null }).previousRemoteJid = received.key.remoteJid; (received.key as { previousRemoteJid?: string | null }).previousRemoteJid = received.key.remoteJid;
received.key.remoteJid = received.key.senderPn; received.key.remoteJid = received.key.senderPn;
@ -1336,12 +1339,19 @@ export class BaileysStartupService extends ChannelStartupService {
this.sendDataWebhook(Events.MESSAGES_UPSERT, messageRaw); this.sendDataWebhook(Events.MESSAGES_UPSERT, messageRaw);
this.logger.log(`🤖 [Baileys] Calling chatbotController.emit for remoteJid: ${messageRaw.key.remoteJid}`);
try {
await chatbotController.emit({ await chatbotController.emit({
instance: { instanceName: this.instance.name, instanceId: this.instanceId }, instance: { instanceName: this.instance.name, instanceId: this.instanceId },
remoteJid: messageRaw.key.remoteJid, remoteJid: messageRaw.key.remoteJid,
msg: messageRaw, msg: messageRaw,
pushName: messageRaw.pushName, pushName: messageRaw.pushName,
}); });
this.logger.log(`✅ [Baileys] chatbotController.emit completed successfully`);
} catch (error) {
this.logger.error(`❌ [Baileys] Error in chatbotController.emit: ${error.message}`);
}
const contact = await this.prismaRepository.contact.findFirst({ const contact = await this.prismaRepository.contact.findFirst({
where: { remoteJid: received.key.remoteJid, instanceId: this.instanceId }, where: { remoteJid: received.key.remoteJid, instanceId: this.instanceId },

View File

@ -84,6 +84,8 @@ export class ChatbotController {
pushName?: string; pushName?: string;
isIntegration?: boolean; isIntegration?: boolean;
}): Promise<void> { }): Promise<void> {
this.logger.log(`🚀 [ChatbotController] EMIT STARTED - remoteJid: ${remoteJid}, instance: ${instance.instanceName}`);
const emitData = { const emitData = {
instance, instance,
remoteJid, remoteJid,
@ -91,19 +93,40 @@ export class ChatbotController {
pushName, pushName,
isIntegration, isIntegration,
}; };
try {
this.logger.log(`🤖 [ChatbotController] Calling evolutionBotController.emit...`);
await evolutionBotController.emit(emitData); await evolutionBotController.emit(emitData);
this.logger.log(`✅ [ChatbotController] evolutionBotController.emit completed`);
this.logger.log(`🤖 [ChatbotController] Calling typebotController.emit...`);
await typebotController.emit(emitData); await typebotController.emit(emitData);
this.logger.log(`✅ [ChatbotController] typebotController.emit completed`);
this.logger.log(`🤖 [ChatbotController] Calling openaiController.emit...`);
await openaiController.emit(emitData); await openaiController.emit(emitData);
this.logger.log(`✅ [ChatbotController] openaiController.emit completed`);
this.logger.log(`🤖 [ChatbotController] Calling difyController.emit...`);
await difyController.emit(emitData); await difyController.emit(emitData);
this.logger.log(`✅ [ChatbotController] difyController.emit completed`);
this.logger.log(`🤖 [ChatbotController] Calling n8nController.emit...`);
await n8nController.emit(emitData); await n8nController.emit(emitData);
this.logger.log(`✅ [ChatbotController] n8nController.emit completed`);
this.logger.log(`🤖 [ChatbotController] Calling evoaiController.emit...`);
await evoaiController.emit(emitData); await evoaiController.emit(emitData);
this.logger.log(`✅ [ChatbotController] evoaiController.emit completed`);
this.logger.log(`🤖 [ChatbotController] Calling flowiseController.emit...`);
await flowiseController.emit(emitData); await flowiseController.emit(emitData);
this.logger.log(`✅ [ChatbotController] flowiseController.emit completed`);
this.logger.log(`🎉 [ChatbotController] All controllers completed successfully`);
} catch (error) {
this.logger.error(`❌ [ChatbotController] Error in emit: ${error.message}`);
}
} }
public processDebounce( public processDebounce(