fix: mediaUrl fallback to directPath for newsletter uploads

Newsletter endpoints return only direct_path (no url field).
Use direct_path as fallback so mediaUrl is never silently undefined.
Also update WAMediaUploadFunction return type to reflect that
mediaUrl may be undefined when only direct_path is present.

Resolves Copilot review comments on PR #311.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Renato Alcara
2026-03-20 11:59:06 -03:00
parent 60798b77ff
commit 9181d01339
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -992,7 +992,7 @@ export type WAMediaUploadFunction = (
encFilePath: string,
opts: { fileEncSha256B64: string; mediaType: MediaType; timeoutMs?: number; newsletter?: boolean }
) => Promise<{
mediaUrl: string
mediaUrl: string | undefined
directPath: string
meta_hmac?: string
ts?: number
+1 -1
View File
@@ -892,7 +892,7 @@ export const getWAUploadToServer = (
if (result?.url || result?.direct_path) {
urls = {
mediaUrl: result.url!,
mediaUrl: result.url || result.direct_path!,
directPath: result.direct_path!,
meta_hmac: result.meta_hmac,
fbid: result.fbid,