chore: update CHANGELOG for Baileys v7.0.0-rc.2 and implement message content sanitization in Baileys service
Some checks are pending
Build Docker image / Build and Deploy (push) Waiting to run

This commit is contained in:
Davidson Gomes
2025-09-08 19:53:52 -03:00
parent 8830f476e8
commit 6da79f0313
3 changed files with 33 additions and 5 deletions

View File

@@ -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)

4
package-lock.json generated
View File

@@ -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": {

View File

@@ -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),
};