Add links-mode embed thumbnails, item metadata, and media filters

This commit is contained in:
Fisto
2026-09-16 11:44:09 +02:00
parent 1fe204b91e
commit 973b9cff92
23 changed files with 863 additions and 82 deletions
+14 -1
View File
@@ -37,11 +37,22 @@ function mapAttachments(message: any): CoreAttachment[] {
}));
}
/** Dimensions of the first embed part that has them: video, image, then thumbnail. */
function embedDataSize(data: any) {
for (const part of [data?.video, data?.image, data?.thumbnail]) {
if (part && Number.isFinite(part.width) && Number.isFinite(part.height)) {
return { width: part.width, height: part.height };
}
}
return { width: null, height: null };
}
function mapEmbeds(message: any): CoreEmbed[] {
const assetUrl = (value: any) => value?.url ?? (typeof value === "string" ? value : null);
return collectionValues(message?.embeds).map((embed: any) => {
const data = embed?.data ?? embed ?? {};
const size = embedDataSize(data);
return {
type: data.type ?? null,
url: data.url ?? null,
@@ -49,7 +60,9 @@ function mapEmbeds(message: any): CoreEmbed[] {
provider: data.provider?.name ?? null,
videoUrl: assetUrl(data.video),
imageUrl: assetUrl(data.image),
thumbnailUrl: assetUrl(data.thumbnail)
thumbnailUrl: assetUrl(data.thumbnail),
width: size.width,
height: size.height
};
});
}