diff --git a/api/funkwhale_api/audio/serializers.py b/api/funkwhale_api/audio/serializers.py index 7d6b1566d..b0bd1a46d 100644 --- a/api/funkwhale_api/audio/serializers.py +++ b/api/funkwhale_api/audio/serializers.py @@ -263,6 +263,7 @@ class ChannelSerializer(serializers.ModelSerializer): attributed_to = federation_serializers.APIActorSerializer() rss_url = serializers.CharField(source="get_rss_url") url = serializers.SerializerMethodField() + subscriptions_count = serializers.SerializerMethodField() class Meta: model = models.Channel @@ -276,6 +277,7 @@ class ChannelSerializer(serializers.ModelSerializer): "rss_url", "url", "downloads_count", + "subscriptions_count", ] def to_representation(self, obj): @@ -284,6 +286,7 @@ class ChannelSerializer(serializers.ModelSerializer): data["subscriptions_count"] = self.get_subscriptions_count(obj) return data + @extend_schema_field(OpenApiTypes.INT) def get_subscriptions_count(self, obj) -> int: return obj.actor.received_follows.exclude(approved=False).count() diff --git a/api/funkwhale_api/common/schema.yml b/api/funkwhale_api/common/schema.yml index df4076f63..fd81f89e0 100644 --- a/api/funkwhale_api/common/schema.yml +++ b/api/funkwhale_api/common/schema.yml @@ -20288,12 +20288,16 @@ components: downloads_count: type: integer readOnly: true + subscriptions_count: + type: integer + readOnly: true required: - actor - artist - attributed_to - downloads_count - rss_url + - subscriptions_count - url ChannelCreate: type: object @@ -25766,7 +25770,6 @@ components: - import_details - metadata - mimetype - - privacy_level - size - uuid UploadForOwnerRequest: @@ -25804,7 +25807,6 @@ components: writeOnly: true required: - audio_file - - privacy_level Usage: type: object properties: diff --git a/api/tests/audio/test_serializers.py b/api/tests/audio/test_serializers.py index c48505779..6de46c1ff 100644 --- a/api/tests/audio/test_serializers.py +++ b/api/tests/audio/test_serializers.py @@ -230,6 +230,7 @@ def test_channel_serializer_representation(factories, to_api_date): "rss_url": channel.get_rss_url(), "url": channel.actor.url, "downloads_count": 12, + "subscriptions_count": 0, } expected["artist"]["description"] = common_serializers.ContentSerializer( content @@ -254,6 +255,7 @@ def test_channel_serializer_external_representation(factories, to_api_date): "rss_url": channel.get_rss_url(), "url": channel.actor.url, "downloads_count": 0, + "subscriptions_count": 0, } expected["artist"]["description"] = common_serializers.ContentSerializer( content