fedimbed: oop

This commit is contained in:
Cynthia Foxwell 2025-04-17 22:24:35 -06:00
parent 9f5ebe42fa
commit 72459f8dc4
Signed by: Cynosphere
SSH key fingerprint: SHA256:H3SM8ufP/uxqLwKSH7xY89TDnbR9uOHzjLoBr0tlajk

View file

@ -946,25 +946,26 @@ async function fetchPost(url, platform, forceMastoAPI = false) {
async function getStatsAS(post) { async function getStatsAS(post) {
// agony // agony
let replyCount = 0; let replyCount = 0;
try { if (post?.replies?.id)
const selfReplies = await signedFetch(post.replies.id + "?page=true", { try {
headers: { const selfReplies = await signedFetch(post.replies.id + "?page=true", {
"User-Agent": FRIENDLY_USERAGENT, headers: {
Accept: "application/activity+json", "User-Agent": FRIENDLY_USERAGENT,
}, Accept: "application/activity+json",
}).then((res) => res.json()); },
replyCount += selfReplies?.items?.length ?? 0; }).then((res) => res.json());
replyCount += selfReplies?.items?.length ?? 0;
const otherReplies = await signedFetch(post.replies.id + "?page=true&only_other_accounts=true", { const otherReplies = await signedFetch(post.replies.id + "?page=true&only_other_accounts=true", {
headers: { headers: {
"User-Agent": FRIENDLY_USERAGENT, "User-Agent": FRIENDLY_USERAGENT,
Accept: "application/activity+json", Accept: "application/activity+json",
}, },
}).then((res) => res.json()); }).then((res) => res.json());
replyCount += otherReplies?.items?.length ?? 0; replyCount += otherReplies?.items?.length ?? 0;
} catch { } catch {
// noop // noop
} }
const stats = []; const stats = [];
if (replyCount > 0) stats.push(`\u21a9 ${statsFormatter.format(replyCount)}`); if (replyCount > 0) stats.push(`\u21a9 ${statsFormatter.format(replyCount)}`);