Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/api/integrations/channel/whatsapp/baileysMessage.processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ export class BaileysMessageProcessor {
}>();

mount({ onMessageReceive }: MountProps) {
// Se já existe subscription, fazer cleanup primeiro
if (this.subscription && !this.subscription.closed) {
this.subscription.unsubscribe();
}

// Se o Subject foi completado, recriar
if (this.messageSubject.closed) {
this.processorLogs.warn('MessageSubject was closed, recreating...');
this.messageSubject = new Subject<{
messages: WAMessage[];
type: MessageUpsertType;
requestId?: string;
settings: any;
}>();
}

this.subscription = this.messageSubject
.pipe(
tap(({ messages }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
import { Instance, Message } from '@prisma/client';
import { createJid } from '@utils/createJid';
import { fetchLatestWaWebVersion } from '@utils/fetchLatestWaWebVersion';
import { makeProxyAgent } from '@utils/makeProxyAgent';

Check failure on line 85 in src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

View workflow job for this annotation

GitHub Actions / check-lint-and-build

Replace `makeProxyAgent,·makeProxyAgentUndici` with `·makeProxyAgent,·makeProxyAgentUndici·`
import { getOnWhatsappCache, saveOnWhatsappCache } from '@utils/onWhatsappCache';
import { status } from '@utils/renderStatus';
import { sendTelemetry } from '@utils/sendTelemetry';
Expand Down Expand Up @@ -710,6 +710,11 @@
this.loadWebhook();
this.loadProxy();

// Remontar o messageProcessor para garantir que está funcionando após reconexão
this.messageProcessor.mount({
onMessageReceive: this.messageHandle['messages.upsert'].bind(this),
});

return await this.createClient(number);
} catch (error) {
this.logger.error(error);
Expand Down
Loading