Skip to content

Commit

Permalink
Ensure that account endpoints return deduped follow counts (#261)
Browse files Browse the repository at this point in the history
no refs
  • Loading branch information
mike182uk authored Jan 15, 2025
1 parent 3b2cfa8 commit f410f44
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/http/api/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ async function getLikedCount(db: KvStore) {
* @param db Database instance
*/
async function getFollowingCount(db: KvStore) {
const following = await db.get<string[]>(['following']);
const following = [
...new Set((await db.get<string[]>(['following'])) || []),
];

return following?.length || 0;
}
Expand All @@ -145,7 +147,9 @@ async function getFollowingCount(db: KvStore) {
* @param db Database instance
*/
async function getFollowerCount(db: KvStore) {
const followers = await db.get<string[]>(['followers']);
const followers = [
...new Set((await db.get<string[]>(['followers'])) || []),
];

return followers?.length || 0;
}
Expand Down Expand Up @@ -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<string[]>([type])) || [];
const follows = [...new Set((await db.get<string[]>([type])) || [])];

const next =
follows.length > offset + FOLLOWS_LIMIT
Expand Down

0 comments on commit f410f44

Please sign in to comment.