From 3fedd0d1d503b0fd9f20b4beb17948a774398ff9 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 7 Jan 2026 02:19:09 +0000 Subject: [PATCH] fix(outbound): guard optional delivery fields --- src/infra/outbound/format.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/infra/outbound/format.ts b/src/infra/outbound/format.ts index 7d7817dcb..e3133e65f 100644 --- a/src/infra/outbound/format.ts +++ b/src/infra/outbound/format.ts @@ -56,10 +56,18 @@ export function buildOutboundDeliveryJson(params: { mediaUrl: params.mediaUrl ?? null, }; - if (result?.chatId !== undefined) payload.chatId = result.chatId; - if (result?.channelId !== undefined) payload.channelId = result.channelId; - if (result?.timestamp !== undefined) payload.timestamp = result.timestamp; - if (result?.toJid !== undefined) payload.toJid = result.toJid; + if (result && "chatId" in result && result.chatId !== undefined) { + payload.chatId = result.chatId; + } + if (result && "channelId" in result && result.channelId !== undefined) { + payload.channelId = result.channelId; + } + if (result && "timestamp" in result && result.timestamp !== undefined) { + payload.timestamp = result.timestamp; + } + if (result && "toJid" in result && result.toJid !== undefined) { + payload.toJid = result.toJid; + } return payload; }