Allow single IDs in familiar_followers

Fixes #547
This commit is contained in:
Andrew Godwin 2023-03-22 16:21:30 -06:00
parent 1994671541
commit ea7d5f307c
2 changed files with 17 additions and 6 deletions

View file

@ -75,10 +75,16 @@ def update_credentials(
@scope_required("read")
@api_view.get
def account_relationships(request, id: list[str] | None) -> list[schemas.Relationship]:
def account_relationships(
request, id: list[str] | str | None
) -> list[schemas.Relationship]:
result = []
# ID is actually a list. Thanks Mastodon!
ids = id or []
if isinstance(id, str):
ids = [id]
elif id is None:
ids = []
else:
ids = id
for actual_id in ids:
identity = get_object_or_404(Identity, pk=actual_id)
result.append(
@ -90,12 +96,17 @@ def account_relationships(request, id: list[str] | None) -> list[schemas.Relatio
@scope_required("read")
@api_view.get
def familiar_followers(
request, id: list[str] | None
request, id: list[str] | str | None
) -> list[schemas.FamiliarFollowers]:
"""
Returns people you follow that also follow given account IDs
"""
ids = id or []
if isinstance(id, str):
ids = [id]
elif id is None:
ids = []
else:
ids = id
result = []
for actual_id in ids:
target_identity = get_object_or_404(Identity, pk=actual_id)

View file

@ -5,7 +5,7 @@ dj_database_url~=1.0.0
django-cache-url~=3.4.2
django-cors-headers~=3.13.0
django-debug-toolbar~=3.8.1
django-hatchway~=0.5.0
django-hatchway~=0.5.1
django-htmx~=1.13.0
django-oauth-toolkit~=2.2.0
django-storages[google,boto3]~=1.13.1