From 9acccf723d2ba5b30e4fd92f09dda72f60dd33bf Mon Sep 17 00:00:00 2001 From: Rafael Souza Date: Tue, 8 Jul 2025 17:43:21 -0300 Subject: [PATCH] Throw exception if download media fail --- .../integrations/channel/whatsapp/whatsapp.baileys.service.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts index c6634f1d..22cdb272 100644 --- a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts +++ b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts @@ -3505,6 +3505,8 @@ export class BaileysStartupService extends ChannelStartupService { this.logger.error('Download Media failed, trying to retry in 5 seconds...'); await new Promise((resolve) => setTimeout(resolve, 5000)); const mediaType = Object.keys(msg.message).find((key) => key.endsWith('Message')); + if (!mediaType) throw new Error('Could not determine mediaType for fallback'); + try { const media = await downloadContentFromMessage( { @@ -3523,6 +3525,7 @@ export class BaileysStartupService extends ChannelStartupService { this.logger.info('Download Media with downloadContentFromMessage was successful!'); } catch (fallbackErr) { this.logger.error('Download Media with downloadContentFromMessage also failed!'); + throw fallbackErr; } } const typeMessage = getContentType(msg.message);