From 70d4f27abd97ce041da70519b58b11e241e8d93a Mon Sep 17 00:00:00 2001 From: devlikepro Date: Fri, 11 Jul 2025 15:28:06 +0700 Subject: [PATCH] [core] WEBJS - ignore old reactions fixes #494 --- src/core/engines/webjs/session.webjs.core.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/core/engines/webjs/session.webjs.core.ts b/src/core/engines/webjs/session.webjs.core.ts index 4ba35cf6..06a91205 100644 --- a/src/core/engines/webjs/session.webjs.core.ts +++ b/src/core/engines/webjs/session.webjs.core.ts @@ -159,6 +159,7 @@ export class WhatsappSessionWebJSCore extends WhatsappSession { private startDelayedJob: SingleDelayedJobRunner; private engineStateCheckDelayedJob: SingleDelayedJobRunner; private shouldRestart: boolean; + private lastQRDate: Date = null; whatsapp: WebjsClientCore; protected qr: QR; @@ -442,6 +443,7 @@ export class WhatsappSessionWebJSCore extends WhatsappSession { this.qr.save(qr); this.printQR(this.qr); this.status = WAHASessionStatus.SCAN_QR_CODE; + this.lastQRDate = new Date(); }); this.whatsapp.on(Events.READY, () => { @@ -1469,6 +1471,7 @@ export class WhatsappSessionWebJSCore extends WhatsappSession { const messageReaction$ = fromEvent(this.whatsapp, 'message_reaction'); const messagesReaction$ = messageReaction$.pipe( map(this.processMessageReaction.bind(this)), + filter(Boolean), ); this.events2.get(WAHAEvents.MESSAGE_REACTION).switch(messagesReaction$); @@ -1649,6 +1652,14 @@ export class WhatsappSessionWebJSCore extends WhatsappSession { } private processMessageReaction(reaction: Reaction): WAMessageReaction { + if (this.lastQRDate) { + // If it's timestamp before last qr - ignore it + // Fixes: https://github.com/devlikeapro/waha/issues/494 + if (reaction.timestamp < this.lastQRDate.getTime() / 1000) { + return null; + } + } + const source = this.getMessageSource(reaction.id.id); return { id: reaction.id._serialized,