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) {
|
||||
// agony
|
||||
let replyCount = 0;
|
||||
try {
|
||||
const selfReplies = await signedFetch(post.replies.id + "?page=true", {
|
||||
headers: {
|
||||
"User-Agent": FRIENDLY_USERAGENT,
|
||||
Accept: "application/activity+json",
|
||||
},
|
||||
}).then((res) => res.json());
|
||||
replyCount += selfReplies?.items?.length ?? 0;
|
||||
if (post?.replies?.id)
|
||||
try {
|
||||
const selfReplies = await signedFetch(post.replies.id + "?page=true", {
|
||||
headers: {
|
||||
"User-Agent": FRIENDLY_USERAGENT,
|
||||
Accept: "application/activity+json",
|
||||
},
|
||||
}).then((res) => res.json());
|
||||
replyCount += selfReplies?.items?.length ?? 0;
|
||||
|
||||
const otherReplies = await signedFetch(post.replies.id + "?page=true&only_other_accounts=true", {
|
||||
headers: {
|
||||
"User-Agent": FRIENDLY_USERAGENT,
|
||||
Accept: "application/activity+json",
|
||||
},
|
||||
}).then((res) => res.json());
|
||||
replyCount += otherReplies?.items?.length ?? 0;
|
||||
} catch {
|
||||
// noop
|
||||
}
|
||||
const otherReplies = await signedFetch(post.replies.id + "?page=true&only_other_accounts=true", {
|
||||
headers: {
|
||||
"User-Agent": FRIENDLY_USERAGENT,
|
||||
Accept: "application/activity+json",
|
||||
},
|
||||
}).then((res) => res.json());
|
||||
replyCount += otherReplies?.items?.length ?? 0;
|
||||
} catch {
|
||||
// noop
|
||||
}
|
||||
|
||||
const stats = [];
|
||||
if (replyCount > 0) stats.push(`\u21a9 ${statsFormatter.format(replyCount)}`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue