Skip to content

Commit

Permalink
Added missing isFollowing property to follows API (#292)
Browse files Browse the repository at this point in the history
ref https://linear.app/ghost/issue/AP-690

Pretty much whenever we return external accounts we need to know whether or not
we're following them so that we can correctly render follow/unfollow buttons
  • Loading branch information
allouis authored Jan 30, 2025
1 parent 1362420 commit 560447c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/http/api/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ const FOLLOWS_LIMIT = 20;
/**
* Follow account shape - Used when returning a list of follow accounts
*/
type FollowAccount = Pick<AccountDTO, 'id' | 'name' | 'handle' | 'avatarUrl'>;
type FollowAccount = Pick<
AccountDTO,
'id' | 'name' | 'handle' | 'avatarUrl'
> & { isFollowing: boolean };

/**
* Compute the handle for an account from the provided host and username
Expand Down Expand Up @@ -194,6 +197,13 @@ export function createGetAccountFollowsHandler(accountService: AccountService) {
name: result.name || '',
handle: getHandle(new URL(result.ap_id).host, result.username),
avatarUrl: result.avatar_url || '',
isFollowing:
type === 'following'
? true
: await accountService.checkIfAccountIsFollowing(
siteDefaultAccount,
result,
),
});
}

Expand Down

0 comments on commit 560447c

Please sign in to comment.