From 308e38b4db70c7ca1bd9bbf68520917d41a5c2b7 Mon Sep 17 00:00:00 2001 From: Agate Date: Tue, 28 Jul 2020 09:41:43 +0200 Subject: [PATCH] Fixed channels not displaying on user profile --- api/funkwhale_api/common/filters.py | 2 +- api/tests/audio/test_views.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/api/funkwhale_api/common/filters.py b/api/funkwhale_api/common/filters.py index 20c3822b7..5807d369f 100644 --- a/api/funkwhale_api/common/filters.py +++ b/api/funkwhale_api/common/filters.py @@ -227,7 +227,7 @@ class ActorScopeFilter(filters.CharFilter): username, domain = full_username.split("@") try: actor = federation_models.Actor.objects.get( - preferred_username=username, domain_id=domain, + preferred_username__iexact=username, domain_id=domain, ) except federation_models.Actor.DoesNotExist: raise EmptyQuerySet() diff --git a/api/tests/audio/test_views.py b/api/tests/audio/test_views.py index 63cb2ebf9..83a211ee4 100644 --- a/api/tests/audio/test_views.py +++ b/api/tests/audio/test_views.py @@ -435,3 +435,18 @@ def test_refresh_channel_when_param_is_true( assert response.status_code == 200 assert refetch_obj.call_count == 1 assert refetch_obj.call_args[0][0] == obj + + +def test_can_filter_channels_through_api_scope(factories, logged_in_api_client): + channel = factories["audio.Channel"]( + attributed_to__preferred_username="PauseLecturePod" + ) + factories["audio.Channel"]() + url = reverse("api:v1:channels-list") + response = logged_in_api_client.get( + url, {"scope": "actor:{}".format(channel.attributed_to.full_username)} + ) + + assert response.status_code == 200 + assert len(response.data["results"]) == 1 + assert response.data["results"][0]["uuid"] == channel.uuid