diff --git a/src/modules/fedimbed.js b/src/modules/fedimbed.js index 3268e1d..857d8c2 100644 --- a/src/modules/fedimbed.js +++ b/src/modules/fedimbed.js @@ -128,16 +128,18 @@ async function processUrl(msg, url, spoiler = false) { "fedimbed", `Failed to signed fetch "${url}", retrying unsigned: ${err}` ); - rawPostData = await fetch(url, { - headers: { - "User-Agent": FRIENDLY_USERAGENT, - Accept: "application/activity+json", - }, - }) - .then((res) => res.text()) - .catch((err) => { - logger.error("fedimbed", `Failed to fetch "${url}": ${err}`); - }); + } + if (!rawPostData) { + try { + rawPostData = await fetch(url, { + headers: { + "User-Agent": FRIENDLY_USERAGENT, + Accept: "application/activity+json", + }, + }).then((res) => res.text()); + } catch (err) { + logger.error("fedimbed", `Failed to fetch "${url}": ${err}`); + } } let postData; @@ -223,21 +225,23 @@ async function processUrl(msg, url, spoiler = false) { "fedimbed", `Failed to signed fetch "${url}" via MastoAPI, retrying unsigned: ${err}` ); - rawPostData2 = await signedFetch( - redirUrl, - Object.assign(options, { - headers: Object.assign(headers, { - "User-Agent": FRIENDLY_USERAGENT, - }), - }) - ) - .then((res) => res.text()) - .catch((err) => { - logger.error( - "fedimbed", - `Failed to fetch "${url}" via MastoAPI: ${err}` - ); - }); + } + if (!rawPostData2) { + try { + rawPostData2 = await signedFetch( + redirUrl, + Object.assign(options, { + headers: Object.assign(headers, { + "User-Agent": FRIENDLY_USERAGENT, + }), + }) + ).then((res) => res.text()); + } catch (err) { + logger.error( + "fedimbed", + `Failed to fetch "${url}" via MastoAPI: ${err}` + ); + } } let postData2;