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:
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user