diff --git a/src/core/engines/webjs/session.webjs.core.ts b/src/core/engines/webjs/session.webjs.core.ts index 8f3e96e4..c68bcd7e 100644 --- a/src/core/engines/webjs/session.webjs.core.ts +++ b/src/core/engines/webjs/session.webjs.core.ts @@ -207,6 +207,7 @@ export class WhatsappSessionWebJSCore extends WhatsappSession { private engineStateCheckDelayedJob: SingleDelayedJobRunner; private shouldRestart: boolean; private lastQRDate: Date = null; + private static readonly REACTION_MAX_AGE_MS = 2 * 24 * 60 * 60 * 1000; whatsapp: WebjsClientCore; protected qr: QR; @@ -2026,6 +2027,14 @@ export class WhatsappSessionWebJSCore extends WhatsappSession { } } + // Ignore reactions older than 2 days to prevent stale reactions + // when session reconnects and replays buffered events + const twoDaysAgoSec = + (Date.now() - WhatsappSessionWebJSCore.REACTION_MAX_AGE_MS) / 1000; + if (reaction.timestamp < twoDaysAgoSec) { + return null; + } + const source = this.getMessageSource(reaction.id.id); return { id: reaction.id._serialized,