From ae31b1e720719fd06e2c94a64496be5d38803c6a Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Fri, 13 Mar 2020 12:58:39 +0100 Subject: [PATCH] =?UTF-8?q?See=20#170:=20display=20info=20that=20RSS=C2=A0?= =?UTF-8?q?feed=20is=20mirrored?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/funkwhale_api/audio/serializers.py | 5 +++++ api/tests/audio/test_serializers.py | 2 ++ front/src/views/channels/DetailBase.vue | 12 ++++++++++++ 3 files changed, 19 insertions(+) diff --git a/api/funkwhale_api/audio/serializers.py b/api/funkwhale_api/audio/serializers.py index 2f6b76442..2e412c3e9 100644 --- a/api/funkwhale_api/audio/serializers.py +++ b/api/funkwhale_api/audio/serializers.py @@ -239,6 +239,7 @@ class ChannelSerializer(serializers.ModelSerializer): actor = serializers.SerializerMethodField() attributed_to = federation_serializers.APIActorSerializer() rss_url = serializers.CharField(source="get_rss_url") + url = serializers.SerializerMethodField() class Meta: model = models.Channel @@ -250,6 +251,7 @@ class ChannelSerializer(serializers.ModelSerializer): "creation_date", "metadata", "rss_url", + "url", ] def get_artist(self, obj): @@ -269,6 +271,9 @@ class ChannelSerializer(serializers.ModelSerializer): return None return federation_serializers.APIActorSerializer(obj.actor).data + def get_url(self, obj): + return obj.actor.url + class SubscriptionSerializer(serializers.Serializer): approved = serializers.BooleanField(read_only=True) diff --git a/api/tests/audio/test_serializers.py b/api/tests/audio/test_serializers.py index add106888..1b647389a 100644 --- a/api/tests/audio/test_serializers.py +++ b/api/tests/audio/test_serializers.py @@ -227,6 +227,7 @@ def test_channel_serializer_representation(factories, to_api_date): ).data, "metadata": {}, "rss_url": channel.get_rss_url(), + "url": channel.actor.url, } expected["artist"]["description"] = common_serializers.ContentSerializer( content @@ -249,6 +250,7 @@ def test_channel_serializer_external_representation(factories, to_api_date): ).data, "metadata": {}, "rss_url": channel.get_rss_url(), + "url": channel.actor.url, } expected["artist"]["description"] = common_serializers.ContentSerializer( content diff --git a/front/src/views/channels/DetailBase.vue b/front/src/views/channels/DetailBase.vue index ca086d5f9..9250cc588 100644 --- a/front/src/views/channels/DetailBase.vue +++ b/front/src/views/channels/DetailBase.vue @@ -128,6 +128,12 @@
{{ object.actor.full_username }}
+
+ + + Mirrored from %{ domain } + +
@@ -298,6 +304,12 @@ export default { } }, computed: { + externalDomain () { + let parser = document.createElement('a') + parser.href = this.object.url || this.object.rss_url + return parser.hostname + }, + isOwner () { return this.$store.state.auth.authenticated && this.object.attributed_to.full_username === this.$store.state.auth.fullUsername },