fedimbed: mastodon makes every attachment Document smh

This commit is contained in:
Cynthia Foxwell 2025-04-18 18:24:01 -06:00
parent 6f8596a55f
commit 3e574fd637
Signed by: Cynosphere
SSH key fingerprint: SHA256:H3SM8ufP/uxqLwKSH7xY89TDnbR9uOHzjLoBr0tlajk

View file

@ -1167,7 +1167,8 @@ async function processUrl(msg, url, spoiler = false, command = false) {
const attachments = Array.isArray(postData.attachment) ? postData.attachment : [postData.attachment]; const attachments = Array.isArray(postData.attachment) ? postData.attachment : [postData.attachment];
for (const attachment of attachments) { for (const attachment of attachments) {
if (attachment.url) { if (attachment.url) {
const type = attachment.type?.toLowerCase(); const type = attachment.type?.toLowerCase() ?? "";
const mediaType = attachment.mediaType ?? "";
let attUrl = attachment.url; let attUrl = attachment.url;
if (Array.isArray(attachment.url)) { if (Array.isArray(attachment.url)) {
@ -1188,17 +1189,17 @@ async function processUrl(msg, url, spoiler = false, command = false) {
} }
const attDesc = attachment.name ?? attachment.description ?? attachment.comment; const attDesc = attachment.name ?? attachment.description ?? attachment.comment;
if (type.startsWith("image")) { if (type.startsWith("image") || mediaType.startsWith("image")) {
images.push({ images.push({
media: {url: attUrl}, media: {url: attUrl},
description: attDesc?.length > 0 ? attDesc : null, description: attDesc?.length > 0 ? attDesc : null,
}); });
} else if (type.startsWith("video")) { } else if (type.startsWith("video") || mediaType.startsWith("video")) {
videos.push({ videos.push({
media: {url: attUrl}, media: {url: attUrl},
description: attDesc?.length > 0 ? attDesc : null, description: attDesc?.length > 0 ? attDesc : null,
}); });
} else if (type.startsWith("audio")) { } else if (type.startsWith("audio") || mediaType.startsWith("audio")) {
audios.push({ audios.push({
url: attUrl, url: attUrl,
description: attDesc?.length > 0 ? attDesc : null, description: attDesc?.length > 0 ? attDesc : null,