diff --git a/CHANGELOG.md b/CHANGELOG.md index 2da6ea6c..00151ffe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ### Testing -* Baileys Updates: Support LIDs in Baileys ([Commit 20693a5](https://github.com/WhiskeySockets/Baileys/commit/20693a59d0973fbf57b28de1b90c55484ce27f8e)) +* Baileys Updates: v7.0.0-rc.2 ([Link](https://github.com/WhiskeySockets/Baileys/releases/tag/v7.0.0-rc.2)) # 2.3.2 (2025-09-02) diff --git a/package-lock.json b/package-lock.json index af71999a..e9c87a39 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4986,8 +4986,8 @@ } }, "node_modules/baileys": { - "version": "6.7.19", - "resolved": "git+ssh://git@github.com/WhiskeySockets/Baileys.git#20693a59d0973fbf57b28de1b90c55484ce27f8e", + "version": "7.0.0-rc.2", + "resolved": "git+ssh://git@github.com/WhiskeySockets/Baileys.git#7970a6e9af73971a5fb0636aec4255504ac1f161", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts index e66df08e..be3f28df 100644 --- a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts +++ b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts @@ -4299,6 +4299,32 @@ export class BaileysStartupService extends ChannelStartupService { throw new Error('Method not available in the Baileys service'); } + private sanitizeMessageContent(messageContent: any): any { + if (!messageContent) return messageContent; + + // Deep clone to avoid modifying original + const sanitized = JSON.parse(JSON.stringify(messageContent, (key, value) => { + // Convert Long objects to numbers + if (Long.isLong(value)) { + return value.toNumber(); + } + + // Convert Uint8Array to regular arrays or remove them + if (value instanceof Uint8Array) { + return Array.from(value); + } + + // Remove functions and other non-serializable objects + if (typeof value === 'function') { + return undefined; + } + + return value; + })); + + return sanitized; + } + private prepareMessage(message: proto.IWebMessageInfo): any { const contentType = getContentType(message.message); const contentMsg = message?.message[contentType] as any; @@ -4311,10 +4337,12 @@ export class BaileysStartupService extends ChannelStartupService { ? 'VocĂȘ' : message?.participant || (message.key?.participant ? message.key.participant.split('@')[0] : null)), status: status[message.status], - message: { ...message.message }, + message: this.sanitizeMessageContent({ ...message.message }), contextInfo: contentMsg?.contextInfo, messageType: contentType || 'unknown', - messageTimestamp: message.messageTimestamp as number, + messageTimestamp: Long.isLong(message.messageTimestamp) + ? (message.messageTimestamp as Long).toNumber() + : (message.messageTimestamp as number), instanceId: this.instanceId, source: getDevice(message.key.id), };