From 0eccfcb74ee4544df06f05c05e6e24fc8726f1ed Mon Sep 17 00:00:00 2001 From: Michael Barrett Date: Wed, 15 Jan 2025 17:08:10 +0000 Subject: [PATCH] Ensure that account endpoints return deduped follow counts no refs --- src/http/api/accounts.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/http/api/accounts.ts b/src/http/api/accounts.ts index 48dc03dc..b6d90719 100644 --- a/src/http/api/accounts.ts +++ b/src/http/api/accounts.ts @@ -134,7 +134,9 @@ async function getLikedCount(db: KvStore) { * @param db Database instance */ async function getFollowingCount(db: KvStore) { - const following = await db.get(['following']); + const following = [ + ...new Set((await db.get(['following'])) || []), + ]; return following?.length || 0; } @@ -145,7 +147,9 @@ async function getFollowingCount(db: KvStore) { * @param db Database instance */ async function getFollowerCount(db: KvStore) { - const followers = await db.get(['followers']); + const followers = [ + ...new Set((await db.get(['followers'])) || []), + ]; return followers?.length || 0; } @@ -251,7 +255,7 @@ export async function handleGetAccountFollows(ctx: AppContext) { const offset = Number.parseInt(queryNext); const db = ctx.get('db'); - const follows = (await db.get([type])) || []; + const follows = [...new Set((await db.get([type])) || [])]; const next = follows.length > offset + FOLLOWS_LIMIT