From d3b9db581e679c736078c6194ec88ccaab5f86b2 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Wed, 21 Dec 2022 16:22:17 +0000 Subject: [PATCH] Move familiar followers to right place for URL --- api/views/accounts.py | 54 +++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/api/views/accounts.py b/api/views/accounts.py index c9fe42d..e505df7 100644 --- a/api/views/accounts.py +++ b/api/views/accounts.py @@ -28,6 +28,33 @@ def account_relationships(request): return result +@api_router.get( + "/v1/accounts/familiar_followers", response=list[schemas.FamiliarFollowers] +) +@identity_required +def familiar_followers(request): + """ + Returns people you follow that also follow given account IDs + """ + ids = request.GET.getlist("id[]") + result = [] + for id in ids: + target_identity = get_object_or_404(Identity, pk=id) + result.append( + { + "id": id, + "accounts": [ + identity.to_mastodon_json() + for identity in Identity.objects.filter( + inbound_follows__source=request.identity, + outbound_follows__target=target_identity, + )[:20] + ], + } + ) + return result + + @api_router.get("/v1/accounts/{id}", response=schemas.Account) @identity_required def account(request, id: str): @@ -100,30 +127,3 @@ def account_unfollow(request, id: str): service = IdentityService(identity) service.unfollow_from(request.identity) return service.mastodon_json_relationship(request.identity) - - -@api_router.get( - "/v1/accounts/familiar_followers", response=list[schemas.FamiliarFollowers] -) -@identity_required -def familiar_followers(request): - """ - Returns people you follow that also follow given account IDs - """ - ids = request.GET.getlist("id[]") - result = [] - for id in ids: - target_identity = get_object_or_404(Identity, pk=id) - result.append( - { - "id": id, - "accounts": [ - identity.to_mastodon_json() - for identity in Identity.objects.filter( - inbound_follows__source=request.identity, - outbound_follows__target=target_identity, - )[:20] - ], - } - ) - return result