Use None instead of empty dict for endpoint default value

This commit is contained in:
Mouse Reeve 2021-03-17 13:59:16 -07:00
parent 0d8e1f0ae2
commit ba09377041
2 changed files with 3 additions and 3 deletions

View file

@ -24,7 +24,7 @@ class Person(ActivityObject):
outbox: str outbox: str
followers: str followers: str
publicKey: PublicKey publicKey: PublicKey
endpoints: Dict = field(default_factory=lambda: {}) endpoints: Dict = None
name: str = None name: str = None
summary: str = None summary: str = None
icon: Image = field(default_factory=lambda: {}) icon: Image = field(default_factory=lambda: {})

View file

@ -73,7 +73,7 @@ class ActivitypubFieldMixin:
raise raise
value = getattr(data, "actor") value = getattr(data, "actor")
formatted = self.field_from_activity(value) 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 return
setattr(instance, self.name, formatted) setattr(instance, self.name, formatted)
@ -101,7 +101,7 @@ class ActivitypubFieldMixin:
def field_from_activity(self, value): def field_from_activity(self, value):
""" formatter to convert activitypub into a model 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) value = value.get(self.activitypub_wrapper)
return value return value