forked from mirrors/bookwyrm
Merge pull request #756 from mouse-reeve/user-error
Fixes failed serialization of empty avatar field
This commit is contained in:
commit
284366e46f
3 changed files with 4 additions and 4 deletions
|
@ -75,7 +75,7 @@ class ActivityObject:
|
|||
for field in fields(self):
|
||||
try:
|
||||
value = kwargs[field.name]
|
||||
if value in (None, MISSING):
|
||||
if value in (None, MISSING, {}):
|
||||
raise KeyError()
|
||||
try:
|
||||
is_subclass = issubclass(field.type, ActivityObject)
|
||||
|
|
|
@ -24,7 +24,7 @@ class Person(ActivityObject):
|
|||
outbox: str
|
||||
followers: str
|
||||
publicKey: PublicKey
|
||||
endpoints: Dict
|
||||
endpoints: Dict = None
|
||||
name: str = None
|
||||
summary: str = None
|
||||
icon: Image = field(default_factory=lambda: {})
|
||||
|
|
|
@ -73,7 +73,7 @@ class ActivitypubFieldMixin:
|
|||
raise
|
||||
value = getattr(data, "actor")
|
||||
formatted = self.field_from_activity(value)
|
||||
if formatted is None or formatted is MISSING:
|
||||
if formatted is None or formatted is MISSING or formatted == {}:
|
||||
return
|
||||
setattr(instance, self.name, formatted)
|
||||
|
||||
|
@ -101,7 +101,7 @@ class ActivitypubFieldMixin:
|
|||
|
||||
def field_from_activity(self, value):
|
||||
""" formatter to convert activitypub into a model value """
|
||||
if hasattr(self, "activitypub_wrapper"):
|
||||
if value and hasattr(self, "activitypub_wrapper"):
|
||||
value = value.get(self.activitypub_wrapper)
|
||||
return value
|
||||
|
||||
|
|
Loading…
Reference in a new issue