fix: resolve 4 media embed bugs from testing

1. Video aspect ratio: remove container border/overflow-hidden, use
   preload="metadata" so browser knows dimensions before play
2. YouTube Error 153: remove sandbox attr (too restrictive), add full
   allow permissions (encrypted-media, accelerometer, gyroscope, etc.)
3. Google Images not displaying: detect image Content-Type from HTTP
   response in metadataFetcher, override classifier to create image
   embed for URLs that serve image/* content
4. Audio seeking broken: add HTTP Range request support in uploads
   route (Accept-Ranges, Content-Range, 206 Partial Content)
This commit is contained in:
Jannis Braun
2026-03-21 00:19:04 +01:00
parent ff2decded5
commit c0133397e3
5 changed files with 58 additions and 11 deletions
+23 -7
View File
@@ -75,20 +75,36 @@ export async function resolveEmbeds(
let image: string | null = null;
let siteName: string | null = null;
// Track the effective embed type (may be overridden by Content-Type detection)
let effectiveEmbedType = classification.embedType;
if (classification.embedType === 'image') {
// Direct image URL — no fetch needed, use the URL as the image source
image = url;
} else if (classification.needsMetadataFetch) {
const metadata = await fetchUrlMetadata(url);
if (metadata) {
title = metadata.title;
description = metadata.description;
image = metadata.image;
siteName = metadata.siteName;
// If the URL itself is a direct media resource (detected via Content-Type),
// override the classification instead of trying to use og: metadata
if (metadata.contentType) {
if (metadata.contentType.startsWith('image/')) {
effectiveEmbedType = 'image';
image = url;
} else if (metadata.contentType.startsWith('video/')) {
effectiveEmbedType = 'video';
} else if (metadata.contentType.startsWith('audio/')) {
effectiveEmbedType = 'audio';
}
} else {
title = metadata.title;
description = metadata.description;
image = metadata.image;
siteName = metadata.siteName;
}
}
// For generic embeds, skip if we couldn't extract a title
if (classification.embedType === 'generic' && !title) {
// For generic embeds, skip if we couldn't extract a title and it's not a media URL
if (effectiveEmbedType === 'generic' && !title) {
continue;
}
}
@@ -99,7 +115,7 @@ export async function resolveEmbeds(
messageId: isDm ? null : messageId,
dmMessageId: isDm ? messageId : null,
url,
embedType: classification.embedType,
embedType: effectiveEmbedType,
provider: classification.provider,
title,
description,