Merge pull request #3096 from bookwyrm-social/image-ap-serialization

Changes to how images are serialized
This commit is contained in:
Mouse Reeve 2024-03-02 18:58:08 -08:00 committed by GitHub
commit dd9d68c97d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 4 additions and 4 deletions

View file

@ -1,5 +1,5 @@
""" actor serializer """ """ actor serializer """
from dataclasses import dataclass, field from dataclasses import dataclass
from typing import Dict from typing import Dict
from .base_activity import ActivityObject from .base_activity import ActivityObject
@ -35,7 +35,7 @@ class Person(ActivityObject):
endpoints: Dict = None endpoints: Dict = None
name: str = None name: str = None
summary: str = None summary: str = None
icon: Image = field(default_factory=lambda: {}) icon: Image = None
bookwyrmUser: bool = False bookwyrmUser: bool = False
manuallyApprovesFollowers: str = False manuallyApprovesFollowers: str = False
discoverable: str = False discoverable: str = False

View file

@ -482,7 +482,7 @@ class ImageField(ActivitypubFieldMixin, models.ImageField):
if not url: if not url:
return None return None
return activitypub.Document(url=url, name=alt) return activitypub.Image(url=url, name=alt)
def field_from_activity(self, value, allow_external_connections=True): def field_from_activity(self, value, allow_external_connections=True):
image_slug = value image_slug = value

View file

@ -438,7 +438,7 @@ class ModelFields(TestCase):
) )
) )
self.assertEqual(output.name, "") self.assertEqual(output.name, "")
self.assertEqual(output.type, "Document") self.assertEqual(output.type, "Image")
@responses.activate @responses.activate
def test_image_field_from_activity(self, *_): def test_image_field_from_activity(self, *_):