Unverified Commit 868dacdb authored by Agate's avatar Agate 💬
Browse files

Fixed broken local profile page when allow-list is enabled

parent 9a37d3a8
......@@ -2,7 +2,7 @@ import requests.exceptions
from django.conf import settings
from django.db import transaction
from django.db.models import Count
from django.db.models import Count, Q
from rest_framework import decorators
from rest_framework import mixins
......@@ -282,7 +282,8 @@ class ActorViewSet(mixins.RetrieveModelMixin, viewsets.GenericViewSet):
domain__instance_policy__block_all=True,
)
if preferences.get("moderation__allow_list_enabled"):
qs = qs.filter(domain__allowed=True)
query = Q(domain_id=settings.FUNKWHALE_HOSTNAME) | Q(domain__allowed=True)
qs = qs.filter(query)
return qs
libraries = decorators.action(methods=["get"], detail=True)(
......
......@@ -215,6 +215,21 @@ def test_can_retrieve_actor(factories, api_client, preferences):
assert response.data == expected
def test_can_retrieve_local_actor_with_allow_list_enabled(
factories, api_client, preferences
):
preferences["common__api_authentication_required"] = False
preferences["moderation__allow_list_enabled"] = True
actor = factories["federation.Actor"](local=True)
url = reverse(
"api:v1:federation:actors-detail", kwargs={"full_username": actor.full_username}
)
response = api_client.get(url)
expected = api_serializers.FullActorSerializer(actor).data
assert response.data == expected
@pytest.mark.parametrize(
"object_id, expected_url",
[
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment