Fix attached images
This commit is contained in:
@@ -71,11 +71,17 @@ export function parseVonageInboundMessage(body: unknown): ParsedInboundSms | nul
|
|||||||
if (fileUrl) mediaUrls.push(fileUrl);
|
if (fileUrl) mediaUrls.push(fileUrl);
|
||||||
}
|
}
|
||||||
// Nested media shapes (best-effort)
|
// Nested media shapes (best-effort)
|
||||||
const nestedMediaUrl =
|
const nestedContent =
|
||||||
data.message && typeof data.message === 'object'
|
data.message && typeof data.message === 'object'
|
||||||
? (((data.message as Record<string, unknown>).content as Record<string, unknown> | undefined)?.url as string) || ''
|
? ((data.message as Record<string, unknown>).content as Record<string, unknown> | undefined)
|
||||||
: '';
|
: undefined;
|
||||||
if (nestedMediaUrl) mediaUrls.push(nestedMediaUrl);
|
const nestedDirectUrl = (nestedContent?.url as string) || '';
|
||||||
|
const nestedImageUrl = (nestedContent?.image as Record<string, unknown> | undefined)?.url as string;
|
||||||
|
const nestedVideoUrl = (nestedContent?.video as Record<string, unknown> | undefined)?.url as string;
|
||||||
|
const nestedFileUrl = (nestedContent?.file as Record<string, unknown> | undefined)?.url as string;
|
||||||
|
for (const url of [nestedDirectUrl, nestedImageUrl, nestedVideoUrl, nestedFileUrl]) {
|
||||||
|
if (url) mediaUrls.push(url);
|
||||||
|
}
|
||||||
|
|
||||||
const hasMedia = mediaUrls.length > 0 || channel === 'mms';
|
const hasMedia = mediaUrls.length > 0 || channel === 'mms';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user