From 784f2d9c203412992575b26a81ddb73a4c9ce146 Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Fri, 22 Sep 2023 20:58:42 -0600 Subject: [PATCH] fedimbed: fix emotes for platforms that dont use it, limmy old. redirect --- src/modules/fedimbed.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/modules/fedimbed.js b/src/modules/fedimbed.js index 2cd6e52..94c6187 100644 --- a/src/modules/fedimbed.js +++ b/src/modules/fedimbed.js @@ -105,6 +105,14 @@ async function signedFetch(url, options) { async function processUrl(msg, url, spoiler = false) { let urlObj = new URL(url); + + // some limmy instances have old reddit frontend subdomains + // but these frontends are just frontends and dont actually expose the API + if (urlObj.hostname.startsWith("old.")) { + urlObj.hostname = urlObj.hostname.replace("old.", ""); + url = urlObj.href; + } + let platform = await resolvePlatform(url); let color = PLATFORM_COLORS[platform]; let platformName = platform @@ -364,9 +372,11 @@ async function processUrl(msg, url, spoiler = false) { if (!spoiler && postData.sensitive) { spoiler = true; } - emotes = postData.tag - .filter((x) => !!x.icon) - .map((x) => ({name: x.name, url: x.icon.url})); + + if (postData.tag) + emotes = postData.tag + .filter((x) => !!x.icon) + .map((x) => ({name: x.name, url: x.icon.url})); // NB: gts doesnt send singular attachments as areay const attachments = Array.isArray(postData.attachment)