diff --git a/src/modules/fedimbed.js b/src/modules/fedimbed.js index 9a88e8f..7c5a036 100644 --- a/src/modules/fedimbed.js +++ b/src/modules/fedimbed.js @@ -129,12 +129,15 @@ async function processUrl(msg, url) { } if (redirUrl) { - const postData2 = await fetch(url.replace("notice", "api/v1/statuses"), { - headers: { - "User-Agent": FRIENDLY_USERAGENT, - }, - }) - .then((res) => res.json()) + const rawPostData2 = await fetch( + url.replace("notice", "api/v1/statuses"), + { + headers: { + "User-Agent": FRIENDLY_USERAGENT, + }, + } + ) + .then((res) => res.text()) .catch((err) => { logger.error( "fedimbed", @@ -142,6 +145,13 @@ async function processUrl(msg, url) { ); }); + let postData2; + if (rawPostData2.startsWith("{")) { + postData2 = JSON.parse(rawPostData2); + } else { + logger.warn("fedimbed", `Got non-JSON for "${url}" as MastoAPI: ${rawPostData2}`); + } + if (!postData2) { logger.warn( "fedimbed",