Add links-mode embed thumbnails, item metadata, and media filters
This commit is contained in:
@@ -210,16 +210,32 @@ function mapAttachments(message: any) {
|
||||
}));
|
||||
}
|
||||
|
||||
/** Dimensions of the first embed part that has them: video, image, then thumbnail. */
|
||||
function embedSize(embed: any) {
|
||||
for (const part of [embed?.video, embed?.image, embed?.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) {
|
||||
return (message?.embeds ?? []).map((embed: any) => ({
|
||||
type: embed?.type ?? null,
|
||||
url: embed?.url ?? null,
|
||||
title: embed?.title ?? null,
|
||||
provider: embed?.provider?.name ?? null,
|
||||
videoUrl: embedUrl(embed?.video),
|
||||
imageUrl: embedUrl(embed?.image),
|
||||
thumbnailUrl: embedUrl(embed?.thumbnail)
|
||||
}));
|
||||
return (message?.embeds ?? []).map((embed: any) => {
|
||||
const size = embedSize(embed);
|
||||
|
||||
return {
|
||||
type: embed?.type ?? null,
|
||||
url: embed?.url ?? null,
|
||||
title: embed?.title ?? null,
|
||||
provider: embed?.provider?.name ?? null,
|
||||
videoUrl: embedUrl(embed?.video),
|
||||
imageUrl: embedUrl(embed?.image),
|
||||
thumbnailUrl: embedUrl(embed?.thumbnail),
|
||||
width: size.width,
|
||||
height: size.height
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function mapStickers(message: any) {
|
||||
|
||||
Reference in New Issue
Block a user