fedimbed.bluesky: nullcheck

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

View file

@ -383,7 +383,7 @@ async function blueskyQuoteEmbed(quote) {
const domain = lookup.service.find((service) => service.id === "#atproto_pds").serviceEndpoint; 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}`; const videoUrl = `${domain}/xrpc/com.atproto.sync.getBlob?did=${quote.author.did}&cid=${embed.cid}`;
videos.push({media: {url: videoUrl}, description: embed.alt.length > 0 ? embed.alt : null}); videos.push({media: {url: videoUrl}, description: embed.alt?.length > 0 ? embed.alt : null});
break; break;
} }
case "app.bsky.embed.recordWithMedia#view": { case "app.bsky.embed.recordWithMedia#view": {
@ -399,7 +399,7 @@ async function blueskyQuoteEmbed(quote) {
const domain = lookup.service.find((service) => service.id === "#atproto_pds").serviceEndpoint; 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}`; const videoUrl = `${domain}/xrpc/com.atproto.sync.getBlob?did=${quote.author.did}&cid=${embed.media.cid}`;
videos.push({media: {url: videoUrl}, description: embed.alt.length > 0 ? embed.alt : null}); videos.push({media: {url: videoUrl}, description: embed.alt?.length > 0 ? embed.alt : null});
} }
break; break;
} }
@ -520,7 +520,7 @@ async function bluesky(msg, url, spoiler = false) {
const domain = lookup.service.find((service) => service.id === "#atproto_pds").serviceEndpoint; 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}`; 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.length > 0 ? post.embed.alt : null}); videos.push({media: {url: videoUrl}, description: post.embed.alt?.length > 0 ? post.embed.alt : null});
break; break;
} }
case "app.bsky.embed.record#view": { case "app.bsky.embed.record#view": {
@ -550,7 +550,7 @@ async function bluesky(msg, url, spoiler = false) {
const domain = lookup.service.find((service) => service.id === "#atproto_pds").serviceEndpoint; 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}`; 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.length > 0 ? post.embed.alt : null}); 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") { } else if (post.embed.media.$type === "app.bsky.embed.external#view") {
if (post.embed.media.external.uri.includes("tenor.com")) { if (post.embed.media.external.uri.includes("tenor.com")) {
const url = new URL(post.embed.media.external.uri); const url = new URL(post.embed.media.external.uri);