From fd16c289e0c25f5b3cfb82aab7c653c400321a07 Mon Sep 17 00:00:00 2001 From: Thilo Billerbeck Date: Tue, 24 Dec 2024 23:52:28 +0100 Subject: [PATCH 1/2] fix: append aspect ratio to image blobs --- lib/bluesky.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/bluesky.ts b/lib/bluesky.ts index a2200b8..5dcc4af 100644 --- a/lib/bluesky.ts +++ b/lib/bluesky.ts @@ -134,7 +134,11 @@ export async function generateBlueskyPostFromMastodon(content: string, client: A if (media_attachmentsFiltered.length > 0 && client) { const images: { image: BlobRef, - alt: string + alt: string, + aspectRatio: { + width: number, + height: number, + } }[] = []; for (const media of media_attachmentsFiltered) { const {arrayBuffer, mimeType} = await fetchImageToBytes(media.url) @@ -158,6 +162,10 @@ export async function generateBlueskyPostFromMastodon(content: string, client: A images.push({ image: res.data.blob, alt: media.description ? media.description : '', + aspectRatio: { + width: media.meta.width || media.meta.original.width, + height: media.meta.height || media.meta.original.height, + } }); } From c482266fd343e80669febe6175092c8a48ee86d5 Mon Sep 17 00:00:00 2001 From: Thilo Billerbeck Date: Wed, 25 Dec 2024 00:14:36 +0100 Subject: [PATCH 2/2] fix: strip mastodon links properly --- lib/utils.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/utils.ts b/lib/utils.ts index b884009..d1517d1 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -14,6 +14,12 @@ export function mastodonHtmlToText(html: string) { hashtag.remove() } + const links = root.querySelectorAll('a') + for (const link of links) { + link.replaceWith(` ${link.attributes.href} `) + link.remove() + } + root.removeWhitespace() return convert(root.toString(), {