mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 10:29:20 +02:00
See #170: fixed fetch of channel track not working
This commit is contained in:
parent
1d37a2c819
commit
e7622729a9
7 changed files with 100 additions and 23 deletions
|
@ -1766,6 +1766,7 @@ class ChannelUploadSerializer(jsonld.JsonLdSerializer):
|
|||
disc = serializers.IntegerField(min_value=1, allow_null=True, required=False)
|
||||
album = serializers.URLField(max_length=500, required=False)
|
||||
license = serializers.URLField(allow_null=True, required=False)
|
||||
attributedTo = serializers.URLField(max_length=500, required=False)
|
||||
copyright = TruncatedCharField(
|
||||
truncate_length=music_models.MAX_LENGTHS["COPYRIGHT"],
|
||||
allow_null=True,
|
||||
|
@ -1808,9 +1809,10 @@ class ChannelUploadSerializer(jsonld.JsonLdSerializer):
|
|||
"position": jsonld.first_val(contexts.FW.position),
|
||||
"image": jsonld.first_obj(contexts.AS.image),
|
||||
"tags": jsonld.raw(contexts.AS.tag),
|
||||
"attributedTo": jsonld.first_id(contexts.AS.attributedTo),
|
||||
}
|
||||
|
||||
def validate_album(self, v):
|
||||
def _validate_album(self, v):
|
||||
return utils.retrieve_ap_object(
|
||||
v,
|
||||
actor=actors.get_service_actor(),
|
||||
|
@ -1821,6 +1823,17 @@ class ChannelUploadSerializer(jsonld.JsonLdSerializer):
|
|||
)
|
||||
|
||||
def validate(self, data):
|
||||
if not self.context.get("channel"):
|
||||
if not data.get("attributedTo"):
|
||||
raise serializers.ValidationError(
|
||||
"Missing channel context and no attributedTo available"
|
||||
)
|
||||
actor = actors.get_actor(data["attributedTo"])
|
||||
if not actor.get_channel():
|
||||
raise serializers.ValidationError("Not a channel")
|
||||
self.context["channel"] = actor.get_channel()
|
||||
if data.get("album"):
|
||||
data["album"] = self._validate_album(data["album"])
|
||||
validated_data = super().validate(data)
|
||||
if data.get("content"):
|
||||
validated_data["description"] = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue