From ba09377041b8a772c86f9a71b045dac68755cff0 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 17 Mar 2021 13:59:16 -0700 Subject: [PATCH] Use None instead of empty dict for endpoint default value --- bookwyrm/activitypub/person.py | 2 +- bookwyrm/models/fields.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bookwyrm/activitypub/person.py b/bookwyrm/activitypub/person.py index f2cacc15f..f1298b927 100644 --- a/bookwyrm/activitypub/person.py +++ b/bookwyrm/activitypub/person.py @@ -24,7 +24,7 @@ class Person(ActivityObject): outbox: str followers: str publicKey: PublicKey - endpoints: Dict = field(default_factory=lambda: {}) + endpoints: Dict = None name: str = None summary: str = None icon: Image = field(default_factory=lambda: {}) diff --git a/bookwyrm/models/fields.py b/bookwyrm/models/fields.py index 1ca0b377b..1bdc6c456 100644 --- a/bookwyrm/models/fields.py +++ b/bookwyrm/models/fields.py @@ -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