mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-09 01:49:37 -06:00
Merge pull request #2186 from muriloleal13/fix/baileys-message-processor-reconnection
fix(baileys): resolve incoming message events not working after reconnection
This commit is contained in:
commit
139ad9b3cb
@ -19,6 +19,22 @@ export class BaileysMessageProcessor {
|
|||||||
}>();
|
}>();
|
||||||
|
|
||||||
mount({ onMessageReceive }: MountProps) {
|
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
|
this.subscription = this.messageSubject
|
||||||
.pipe(
|
.pipe(
|
||||||
tap(({ messages }) => {
|
tap(({ messages }) => {
|
||||||
|
|||||||
@ -723,6 +723,11 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
this.loadWebhook();
|
this.loadWebhook();
|
||||||
this.loadProxy();
|
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);
|
return await this.createClient(number);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error(error);
|
this.logger.error(error);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user