fedimbed.bluesky: description hates zero width strings bruh

This commit is contained in:
Cynthia Foxwell 2025-04-18 14:34:25 -06:00
parent 400c6c1ea3
commit 37f2224ad2
Signed by: Cynosphere
SSH key fingerprint: SHA256:H3SM8ufP/uxqLwKSH7xY89TDnbR9uOHzjLoBr0tlajk

View file

@ -370,7 +370,12 @@ async function blueskyQuoteEmbed(quote) {
const embed = quote.embeds[0];
switch (embed.$type) {
case "app.bsky.embed.images#view": {
images.push(...embed.images.map((image) => ({media: {url: image.fullsize}, description: image.alt})));
images.push(
...embed.images.map((image) => ({
media: {url: image.fullsize},
description: image.alt.length > 0 ? image.alt : null,
}))
);
break;
}
case "app.bsky.embed.video#view": {
@ -378,18 +383,23 @@ async function blueskyQuoteEmbed(quote) {
const domain = lookup.service.find((service) => service.id === "#atproto_pds").serviceEndpoint;
const videoUrl = `${domain}/xrpc/com.atproto.sync.getBlob?did=${quote.author.did}&cid=${embed.cid}`;
videos.push({media: {url: videoUrl}, description: embed.alt});
videos.push({media: {url: videoUrl}, description: embed.alt.length > 0 ? embed.alt : null});
break;
}
case "app.bsky.embed.recordWithMedia#view": {
if (embed.media.$type === "app.bsky.embed.images#view") {
images.push(...embed.media.images.map((image) => ({media: {url: image.fullsize}, description: image.alt})));
images.push(
...embed.media.images.map((image) => ({
media: {url: image.fullsize},
description: image.alt.length > 0 ? image.alt : null,
}))
);
} else if (embed.media.$type === "app.bsky.embed.video#view") {
const lookup = await fetch(`https://plc.directory/${quote.author.did}`).then((res) => res.json());
const domain = lookup.service.find((service) => service.id === "#atproto_pds").serviceEndpoint;
const videoUrl = `${domain}/xrpc/com.atproto.sync.getBlob?did=${quote.author.did}&cid=${embed.media.cid}`;
videos.push({media: {url: videoUrl}, description: embed.alt});
videos.push({media: {url: videoUrl}, description: embed.alt.length > 0 ? embed.alt : null});
}
break;
}
@ -497,7 +507,12 @@ async function bluesky(msg, url, spoiler = false) {
if (post.embed) {
switch (post.embed.$type) {
case "app.bsky.embed.images#view": {
images.push(post.embed.images.map((image) => ({media: {url: image.fullsize}, description: image.alt})));
images.push(
post.embed.images.map((image) => ({
media: {url: image.fullsize},
description: image.alt.length > 0 ? image.alt : null,
}))
);
break;
}
case "app.bsky.embed.video#view": {
@ -505,7 +520,7 @@ async function bluesky(msg, url, spoiler = false) {
const domain = lookup.service.find((service) => service.id === "#atproto_pds").serviceEndpoint;
const videoUrl = `${domain}/xrpc/com.atproto.sync.getBlob?did=${post.author.did}&cid=${post.embed.cid}`;
videos.push({media: {url: videoUrl}, description: post.embed.alt});
videos.push({media: {url: videoUrl}, description: post.embed.alt.length > 0 ? post.embed.alt : null});
break;
}
case "app.bsky.embed.record#view": {
@ -524,13 +539,18 @@ async function bluesky(msg, url, spoiler = false) {
hasQuote = true;
if (post.embed.media.$type === "app.bsky.embed.images#view") {
images.push(post.embed.media.images.map((image) => ({media: {url: image.fullsize}, description: image.alt})));
images.push(
post.embed.media.images.map((image) => ({
media: {url: image.fullsize},
description: image.alt.length > 0 ? image.alt : null,
}))
);
} else if (post.embed.media.$type === "app.bsky.embed.video#view") {
const lookup = await fetch(`https://plc.directory/${post.author.did}`).then((res) => res.json());
const domain = lookup.service.find((service) => service.id === "#atproto_pds").serviceEndpoint;
const videoUrl = `${domain}/xrpc/com.atproto.sync.getBlob?did=${post.author.did}&cid=${post.embed.media.cid}`;
videos.push({media: {url: videoUrl}, description: post.embed.alt});
videos.push({media: {url: videoUrl}, description: post.embed.alt.length > 0 ? post.embed.alt : null});
} else if (post.embed.media.$type === "app.bsky.embed.external#view") {
if (post.embed.media.external.uri.includes("tenor.com")) {
const url = new URL(post.embed.media.external.uri);