File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
src/api/integrations/channel/whatsapp Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,22 @@ export class BaileysMessageProcessor {
1919 } > ( ) ;
2020
2121 mount ( { onMessageReceive } : MountProps ) {
22+ // Se já existe subscription, fazer cleanup primeiro
23+ if ( this . subscription && ! this . subscription . closed ) {
24+ this . subscription . unsubscribe ( ) ;
25+ }
26+
27+ // Se o Subject foi completado, recriar
28+ if ( this . messageSubject . closed ) {
29+ this . processorLogs . warn ( 'MessageSubject was closed, recreating...' ) ;
30+ this . messageSubject = new Subject < {
31+ messages : WAMessage [ ] ;
32+ type : MessageUpsertType ;
33+ requestId ?: string ;
34+ settings : any ;
35+ } > ( ) ;
36+ }
37+
2238 this . subscription = this . messageSubject
2339 . pipe (
2440 tap ( ( { messages } ) => {
Original file line number Diff line number Diff line change @@ -723,6 +723,11 @@ export class BaileysStartupService extends ChannelStartupService {
723723 this . loadWebhook ( ) ;
724724 this . loadProxy ( ) ;
725725
726+ // Remontar o messageProcessor para garantir que está funcionando após reconexão
727+ this . messageProcessor . mount ( {
728+ onMessageReceive : this . messageHandle [ 'messages.upsert' ] . bind ( this ) ,
729+ } ) ;
730+
726731 return await this . createClient ( number ) ;
727732 } catch ( error ) {
728733 this . logger . error ( error ) ;
You can’t perform that action at this time.
0 commit comments