Skip to content

Commit afb6484

Browse files
committed
fix: resolve ephemeralMessage crash on iOS audio messages in getBase64FromMediaMessage
When processing iOS audio messages in getBase64FromMediaMessage, the subtype unwrapping loop assumed msg.message[subtype].message always exists if msg.message[subtype] is truthy. iOS ephemeral messages can have ephemeralMessage without the standard .message property, causing 'Cannot read properties of undefined' crashes. - Add guard for msg.message being falsy before the loop - Use optional chaining (msg.message[subtype]?.message) in the loop condition Closes #2550
1 parent 7a55a2b commit afb6484

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4400,8 +4400,12 @@ export class BaileysStartupService extends ChannelStartupService {
44004400
throw 'Message not found';
44014401
}
44024402

4403+
if (!msg.message) {
4404+
throw 'Message not found';
4405+
}
4406+
44034407
for (const subtype of MessageSubtype) {
4404-
if (msg.message[subtype]) {
4408+
if (msg.message[subtype]?.message) {
44054409
msg.message = msg.message[subtype].message;
44064410
}
44074411
}

0 commit comments

Comments
 (0)