This commit is contained in:
@@ -349,10 +349,14 @@ function messageContent(content: unknown, mediaURL: (ref?: string) => string) {
|
||||
const media = drafty.ent?.find((entity) => entity?.tp === 'IM' || entity?.tp === 'VD');
|
||||
if (media?.data) {
|
||||
const type = media.tp === 'VD' ? 'video' : 'image';
|
||||
const inline = typeof media.data.val === 'string' ? media.data.val : '';
|
||||
const mime = typeof media.data.mime === 'string' && media.data.mime.startsWith(`${type}/`)
|
||||
? media.data.mime
|
||||
: type === 'video' ? 'video/webm' : 'image/jpeg';
|
||||
return {
|
||||
text: '',
|
||||
type,
|
||||
media_url: mediaURL(String(media.data.ref || '')),
|
||||
media_url: inline ? `data:${mime};base64,${inline}` : mediaURL(String(media.data.ref || '')),
|
||||
preview_url: mediaURL(String(media.data.preref || '')),
|
||||
file_name: String(media.data.name || ''),
|
||||
} as const;
|
||||
|
||||
Reference in New Issue
Block a user