diff --git a/api/funkwhale_api/manage/serializers.py b/api/funkwhale_api/manage/serializers.py index 38a9cd57a..f5fe1a53b 100644 --- a/api/funkwhale_api/manage/serializers.py +++ b/api/funkwhale_api/manage/serializers.py @@ -1,3 +1,4 @@ +from django.conf import settings from django.db import transaction from rest_framework import serializers @@ -183,6 +184,8 @@ class ManageDomainActionSerializer(common_serializers.ActionSerializer): class ManageBaseActorSerializer(serializers.ModelSerializer): + is_local = serializers.SerializerMethodField() + class Meta: model = federation_models.Actor fields = [ @@ -201,9 +204,13 @@ class ManageBaseActorSerializer(serializers.ModelSerializer): "outbox_url", "shared_inbox_url", "manually_approves_followers", + "is_local", ] read_only_fields = ["creation_date", "instance_policy"] + def get_is_local(self, o): + return o.domain_id == settings.FEDERATION_HOSTNAME + class ManageActorSerializer(ManageBaseActorSerializer): uploads_count = serializers.SerializerMethodField() diff --git a/api/tests/manage/test_serializers.py b/api/tests/manage/test_serializers.py index 7f99dd901..4056c1819 100644 --- a/api/tests/manage/test_serializers.py +++ b/api/tests/manage/test_serializers.py @@ -87,6 +87,7 @@ def test_manage_actor_serializer(factories, now, to_api_date): "full_username": actor.full_username, "user": None, "instance_policy": None, + "is_local": False, } s = serializers.ManageActorSerializer(actor)