fedimbed: oop
This commit is contained in:
parent
9f5ebe42fa
commit
72459f8dc4
1 changed files with 19 additions and 18 deletions
|
@ -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)}`);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue