kopia lustrzana https://dev.funkwhale.audio/funkwhale/funkwhale
Fix #207: Consistent constraints/checks for URL size
rodzic
86211dc515
commit
ae00cccf14
|
@ -0,0 +1,28 @@
|
||||||
|
# Generated by Django 2.0.4 on 2018-05-21 17:02
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('federation', '0005_auto_20180413_1723'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='library',
|
||||||
|
name='url',
|
||||||
|
field=models.URLField(max_length=500),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='librarytrack',
|
||||||
|
name='audio_url',
|
||||||
|
field=models.URLField(max_length=500),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='librarytrack',
|
||||||
|
name='url',
|
||||||
|
field=models.URLField(max_length=500, unique=True),
|
||||||
|
),
|
||||||
|
]
|
|
@ -139,7 +139,7 @@ class Library(models.Model):
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
related_name='library')
|
related_name='library')
|
||||||
uuid = models.UUIDField(default=uuid.uuid4)
|
uuid = models.UUIDField(default=uuid.uuid4)
|
||||||
url = models.URLField()
|
url = models.URLField(max_length=500)
|
||||||
|
|
||||||
# use this flag to disable federation with a library
|
# use this flag to disable federation with a library
|
||||||
federation_enabled = models.BooleanField()
|
federation_enabled = models.BooleanField()
|
||||||
|
@ -166,8 +166,8 @@ def get_file_path(instance, filename):
|
||||||
|
|
||||||
|
|
||||||
class LibraryTrack(models.Model):
|
class LibraryTrack(models.Model):
|
||||||
url = models.URLField(unique=True)
|
url = models.URLField(unique=True, max_length=500)
|
||||||
audio_url = models.URLField()
|
audio_url = models.URLField(max_length=500)
|
||||||
audio_mimetype = models.CharField(max_length=200)
|
audio_mimetype = models.CharField(max_length=200)
|
||||||
audio_file = models.FileField(
|
audio_file = models.FileField(
|
||||||
upload_to=get_file_path,
|
upload_to=get_file_path,
|
||||||
|
|
|
@ -26,16 +26,16 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ActorSerializer(serializers.Serializer):
|
class ActorSerializer(serializers.Serializer):
|
||||||
id = serializers.URLField()
|
id = serializers.URLField(max_length=500)
|
||||||
outbox = serializers.URLField()
|
outbox = serializers.URLField(max_length=500)
|
||||||
inbox = serializers.URLField()
|
inbox = serializers.URLField(max_length=500)
|
||||||
type = serializers.ChoiceField(choices=models.TYPE_CHOICES)
|
type = serializers.ChoiceField(choices=models.TYPE_CHOICES)
|
||||||
preferredUsername = serializers.CharField()
|
preferredUsername = serializers.CharField()
|
||||||
manuallyApprovesFollowers = serializers.NullBooleanField(required=False)
|
manuallyApprovesFollowers = serializers.NullBooleanField(required=False)
|
||||||
name = serializers.CharField(required=False, max_length=200)
|
name = serializers.CharField(required=False, max_length=200)
|
||||||
summary = serializers.CharField(max_length=None, required=False)
|
summary = serializers.CharField(max_length=None, required=False)
|
||||||
followers = serializers.URLField(required=False, allow_null=True)
|
followers = serializers.URLField(max_length=500, required=False, allow_null=True)
|
||||||
following = serializers.URLField(required=False, allow_null=True)
|
following = serializers.URLField(max_length=500, required=False, allow_null=True)
|
||||||
publicKey = serializers.JSONField(required=False)
|
publicKey = serializers.JSONField(required=False)
|
||||||
|
|
||||||
def to_representation(self, instance):
|
def to_representation(self, instance):
|
||||||
|
@ -224,7 +224,7 @@ class APILibraryFollowUpdateSerializer(serializers.Serializer):
|
||||||
|
|
||||||
|
|
||||||
class APILibraryCreateSerializer(serializers.ModelSerializer):
|
class APILibraryCreateSerializer(serializers.ModelSerializer):
|
||||||
actor = serializers.URLField()
|
actor = serializers.URLField(max_length=500)
|
||||||
federation_enabled = serializers.BooleanField()
|
federation_enabled = serializers.BooleanField()
|
||||||
uuid = serializers.UUIDField(read_only=True)
|
uuid = serializers.UUIDField(read_only=True)
|
||||||
|
|
||||||
|
@ -315,9 +315,9 @@ class APILibraryTrackSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
|
|
||||||
class FollowSerializer(serializers.Serializer):
|
class FollowSerializer(serializers.Serializer):
|
||||||
id = serializers.URLField()
|
id = serializers.URLField(max_length=500)
|
||||||
object = serializers.URLField()
|
object = serializers.URLField(max_length=500)
|
||||||
actor = serializers.URLField()
|
actor = serializers.URLField(max_length=500)
|
||||||
type = serializers.ChoiceField(choices=['Follow'])
|
type = serializers.ChoiceField(choices=['Follow'])
|
||||||
|
|
||||||
def validate_object(self, v):
|
def validate_object(self, v):
|
||||||
|
@ -374,8 +374,8 @@ class APIFollowSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
|
|
||||||
class AcceptFollowSerializer(serializers.Serializer):
|
class AcceptFollowSerializer(serializers.Serializer):
|
||||||
id = serializers.URLField()
|
id = serializers.URLField(max_length=500)
|
||||||
actor = serializers.URLField()
|
actor = serializers.URLField(max_length=500)
|
||||||
object = FollowSerializer()
|
object = FollowSerializer()
|
||||||
type = serializers.ChoiceField(choices=['Accept'])
|
type = serializers.ChoiceField(choices=['Accept'])
|
||||||
|
|
||||||
|
@ -417,8 +417,8 @@ class AcceptFollowSerializer(serializers.Serializer):
|
||||||
|
|
||||||
|
|
||||||
class UndoFollowSerializer(serializers.Serializer):
|
class UndoFollowSerializer(serializers.Serializer):
|
||||||
id = serializers.URLField()
|
id = serializers.URLField(max_length=500)
|
||||||
actor = serializers.URLField()
|
actor = serializers.URLField(max_length=500)
|
||||||
object = FollowSerializer()
|
object = FollowSerializer()
|
||||||
type = serializers.ChoiceField(choices=['Undo'])
|
type = serializers.ChoiceField(choices=['Undo'])
|
||||||
|
|
||||||
|
@ -459,9 +459,9 @@ class UndoFollowSerializer(serializers.Serializer):
|
||||||
|
|
||||||
class ActorWebfingerSerializer(serializers.Serializer):
|
class ActorWebfingerSerializer(serializers.Serializer):
|
||||||
subject = serializers.CharField()
|
subject = serializers.CharField()
|
||||||
aliases = serializers.ListField(child=serializers.URLField())
|
aliases = serializers.ListField(child=serializers.URLField(max_length=500))
|
||||||
links = serializers.ListField()
|
links = serializers.ListField()
|
||||||
actor_url = serializers.URLField(required=False)
|
actor_url = serializers.URLField(max_length=500, required=False)
|
||||||
|
|
||||||
def validate(self, validated_data):
|
def validate(self, validated_data):
|
||||||
validated_data['actor_url'] = None
|
validated_data['actor_url'] = None
|
||||||
|
@ -496,8 +496,8 @@ class ActorWebfingerSerializer(serializers.Serializer):
|
||||||
|
|
||||||
|
|
||||||
class ActivitySerializer(serializers.Serializer):
|
class ActivitySerializer(serializers.Serializer):
|
||||||
actor = serializers.URLField()
|
actor = serializers.URLField(max_length=500)
|
||||||
id = serializers.URLField(required=False)
|
id = serializers.URLField(max_length=500, required=False)
|
||||||
type = serializers.ChoiceField(
|
type = serializers.ChoiceField(
|
||||||
choices=[(c, c) for c in activity.ACTIVITY_TYPES])
|
choices=[(c, c) for c in activity.ACTIVITY_TYPES])
|
||||||
object = serializers.JSONField()
|
object = serializers.JSONField()
|
||||||
|
@ -539,8 +539,8 @@ class ActivitySerializer(serializers.Serializer):
|
||||||
|
|
||||||
|
|
||||||
class ObjectSerializer(serializers.Serializer):
|
class ObjectSerializer(serializers.Serializer):
|
||||||
id = serializers.URLField()
|
id = serializers.URLField(max_length=500)
|
||||||
url = serializers.URLField(required=False, allow_null=True)
|
url = serializers.URLField(max_length=500, required=False, allow_null=True)
|
||||||
type = serializers.ChoiceField(
|
type = serializers.ChoiceField(
|
||||||
choices=[(c, c) for c in activity.OBJECT_TYPES])
|
choices=[(c, c) for c in activity.OBJECT_TYPES])
|
||||||
content = serializers.CharField(
|
content = serializers.CharField(
|
||||||
|
@ -554,16 +554,16 @@ class ObjectSerializer(serializers.Serializer):
|
||||||
updated = serializers.DateTimeField(
|
updated = serializers.DateTimeField(
|
||||||
required=False, allow_null=True)
|
required=False, allow_null=True)
|
||||||
to = serializers.ListField(
|
to = serializers.ListField(
|
||||||
child=serializers.URLField(),
|
child=serializers.URLField(max_length=500),
|
||||||
required=False, allow_null=True)
|
required=False, allow_null=True)
|
||||||
cc = serializers.ListField(
|
cc = serializers.ListField(
|
||||||
child=serializers.URLField(),
|
child=serializers.URLField(max_length=500),
|
||||||
required=False, allow_null=True)
|
required=False, allow_null=True)
|
||||||
bto = serializers.ListField(
|
bto = serializers.ListField(
|
||||||
child=serializers.URLField(),
|
child=serializers.URLField(max_length=500),
|
||||||
required=False, allow_null=True)
|
required=False, allow_null=True)
|
||||||
bcc = serializers.ListField(
|
bcc = serializers.ListField(
|
||||||
child=serializers.URLField(),
|
child=serializers.URLField(max_length=500),
|
||||||
required=False, allow_null=True)
|
required=False, allow_null=True)
|
||||||
|
|
||||||
OBJECT_SERIALIZERS = {
|
OBJECT_SERIALIZERS = {
|
||||||
|
@ -575,10 +575,10 @@ OBJECT_SERIALIZERS = {
|
||||||
class PaginatedCollectionSerializer(serializers.Serializer):
|
class PaginatedCollectionSerializer(serializers.Serializer):
|
||||||
type = serializers.ChoiceField(choices=['Collection'])
|
type = serializers.ChoiceField(choices=['Collection'])
|
||||||
totalItems = serializers.IntegerField(min_value=0)
|
totalItems = serializers.IntegerField(min_value=0)
|
||||||
actor = serializers.URLField()
|
actor = serializers.URLField(max_length=500)
|
||||||
id = serializers.URLField()
|
id = serializers.URLField(max_length=500)
|
||||||
first = serializers.URLField()
|
first = serializers.URLField(max_length=500)
|
||||||
last = serializers.URLField()
|
last = serializers.URLField(max_length=500)
|
||||||
|
|
||||||
def to_representation(self, conf):
|
def to_representation(self, conf):
|
||||||
paginator = Paginator(
|
paginator = Paginator(
|
||||||
|
@ -607,13 +607,13 @@ class CollectionPageSerializer(serializers.Serializer):
|
||||||
type = serializers.ChoiceField(choices=['CollectionPage'])
|
type = serializers.ChoiceField(choices=['CollectionPage'])
|
||||||
totalItems = serializers.IntegerField(min_value=0)
|
totalItems = serializers.IntegerField(min_value=0)
|
||||||
items = serializers.ListField()
|
items = serializers.ListField()
|
||||||
actor = serializers.URLField()
|
actor = serializers.URLField(max_length=500)
|
||||||
id = serializers.URLField()
|
id = serializers.URLField(max_length=500)
|
||||||
first = serializers.URLField()
|
first = serializers.URLField(max_length=500)
|
||||||
last = serializers.URLField()
|
last = serializers.URLField(max_length=500)
|
||||||
next = serializers.URLField(required=False)
|
next = serializers.URLField(max_length=500, required=False)
|
||||||
prev = serializers.URLField(required=False)
|
prev = serializers.URLField(max_length=500, required=False)
|
||||||
partOf = serializers.URLField()
|
partOf = serializers.URLField(max_length=500)
|
||||||
|
|
||||||
def validate_items(self, v):
|
def validate_items(self, v):
|
||||||
item_serializer = self.context.get('item_serializer')
|
item_serializer = self.context.get('item_serializer')
|
||||||
|
@ -698,7 +698,7 @@ class AudioMetadataSerializer(serializers.Serializer):
|
||||||
|
|
||||||
class AudioSerializer(serializers.Serializer):
|
class AudioSerializer(serializers.Serializer):
|
||||||
type = serializers.CharField()
|
type = serializers.CharField()
|
||||||
id = serializers.URLField()
|
id = serializers.URLField(max_length=500)
|
||||||
url = serializers.JSONField()
|
url = serializers.JSONField()
|
||||||
published = serializers.DateTimeField()
|
published = serializers.DateTimeField()
|
||||||
updated = serializers.DateTimeField(required=False)
|
updated = serializers.DateTimeField(required=False)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Consistent constraints/checks for URL size (#207)
|
Ładowanie…
Reference in New Issue