From 6ede3ee4a80a82d9c4a9d77bdf122793b06e2369 Mon Sep 17 00:00:00 2001 From: dylan Date: Thu, 25 Dec 2025 20:58:59 +0000 Subject: [PATCH] updated getMastodonPost to use description instead of title for non-reply items, maybe relying on forgejo actions rather than locally testing is making this messy :P --- utils.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/utils.js b/utils.js index 21f087d..03be4c2 100644 --- a/utils.js +++ b/utils.js @@ -84,31 +84,32 @@ export async function getMastodonPost(feedUrl) { // find the first item that isn't a reply (doesn't start with @) for (const item of items) { const description = item.querySelector('description')?.textContent || '' - const title = item.querySelector('title')?.textContent || '' // skip if it's a reply (starts with @ mention) - if (description.trim().startsWith('@') || title.trim().startsWith('@')) { + if (description.trim().startsWith('@')) { continue } const link = item.querySelector('link')?.textContent.trim() - const cleanTitle = sanitizeHtml(title, { + + // use description as the text, stripping HTML + const cleanText = sanitizeHtml(description, { allowedTags: [], allowedAttributes: {}, })?.trim() - return { text: cleanTitle, url: link } + return { text: cleanText, url: link } } // fallback to first item if no non-reply found const firstItem = items[0] - const title = firstItem.querySelector('title').textContent - const link = firstItem.querySelector('link').textContent.trim() - const cleanTitle = sanitizeHtml(title, { + const description = firstItem.querySelector('description')?.textContent || '' + const link = firstItem.querySelector('link')?.textContent.trim() + const cleanText = sanitizeHtml(description, { allowedTags: [], allowedAttributes: {}, })?.trim() - return { text: cleanTitle, url: link } + return { text: cleanText, url: link } } export async function getJsonFeedItemTitle(feedUrl, showImage = true) {