diff --git a/src/core/engines/noweb/session.noweb.core.ts b/src/core/engines/noweb/session.noweb.core.ts index 2bc7645d..4fb8570a 100644 --- a/src/core/engines/noweb/session.noweb.core.ts +++ b/src/core/engines/noweb/session.noweb.core.ts @@ -199,7 +199,10 @@ import { NowebPersistentStore } from './store/NowebPersistentStore'; import { NowebStorageFactoryCore } from './store/NowebStorageFactoryCore'; import { ensureNumber, extractMediaContent } from './utils'; import { Agents } from '@waha/core/engines/noweb/types'; -import { IsEditedMessage } from '@waha/core/utils/pwa'; +import { + IsEditedMessage, + IsHistorySyncNotification, +} from '@waha/core/utils/pwa'; // eslint-disable-next-line @typescript-eslint/no-var-requires const promiseRetry = require('promise-retry'); @@ -2198,6 +2201,10 @@ export class WhatsappSessionNoWebCore extends WhatsappSession { return; // Ignore edit, we have a dedicated event for that if (IsEditedMessage(message.message)) return; + + // Ignore history sync notifications + if (IsHistorySyncNotification(message.message)) return; + if ( message.message?.protocolMessage?.type === proto.Message.ProtocolMessage.Type.EPHEMERAL_SYNC_RESPONSE diff --git a/src/core/utils/pwa.ts b/src/core/utils/pwa.ts index afa70e75..4c7f08b1 100644 --- a/src/core/utils/pwa.ts +++ b/src/core/utils/pwa.ts @@ -20,3 +20,20 @@ export function IsEditedMessage(message: proto.IMessage): boolean { } return true; } + +export function IsHistorySyncNotification(message: proto.IMessage): boolean { + message = normalizeMessageContent(message); + if (!message) { + return false; + } + if ( + message?.protocolMessage?.type !== + proto.Message.ProtocolMessage.Type.HISTORY_SYNC_NOTIFICATION + ) { + return false; + } + if (message?.protocolMessage?.historySyncNotification == null) { + return false; + } + return true; +}