Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(baileys): find a message secret inside three more wrappers

Yudhi Armyndharis3fe379a88ea1
diff --git a/src/engine/adapters/baileys-secret-payload.spec.ts b/src/engine/adapters/baileys-secret-payload.spec.ts
index c81823189..869150710 100644
--- a/src/engine/adapters/baileys-secret-payload.spec.ts
+++ b/src/engine/adapters/baileys-secret-payload.spec.ts
@@ -214,6 +214,13 @@ describe('messageSecretOf', () => {
);
});
+ // The library unwraps these as well when it normalizes a message, so a secret that only sits inside one
+ // (a photo of an album, a group status) has to be found there.
+ it.each(['associatedChildMessage', 'groupStatusMessage', 'groupStatusMessageV2'])('finds it inside %s', wrapper => {
+ const inner = { messageContextInfo: { messageSecret: secretText }, imageMessage: {} };
+ expect(messageSecretOf({ [wrapper]: { message: inner } })).toEqual(Buffer.alloc(32, 7));
+ });
+
it.each([[undefined], [null], [{ conversation: 'x' }], [{ messageContextInfo: {} }], ['text']])(
'answers undefined for %p',
message => {
diff --git a/src/engine/adapters/baileys-secret-payload.ts b/src/engine/adapters/baileys-secret-payload.ts
index 2267420a5..a0f84f6d0 100644
--- a/src/engine/adapters/baileys-secret-payload.ts
+++ b/src/engine/adapters/baileys-secret-payload.ts
@@ -93,6 +93,9 @@ const WRAPPERS = [
'viewOnceMessageV2Extension',
'documentWithCaptionMessage',
'editedMessage',
+ 'associatedChildMessage',
+ 'groupStatusMessage',
+ 'groupStatusMessageV2',
] as const;
/** The secret a message carries, at the top level or inside the wrappers a disappearing chat adds. */