From 35bd4a4071a13047c2c52ef51ef42616b48447d1 Mon Sep 17 00:00:00 2001 From: Joachim Date: Wed, 27 Oct 2021 18:13:47 +0200 Subject: [PATCH] Apply review suggestion --- bookwyrm/models/fields.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bookwyrm/models/fields.py b/bookwyrm/models/fields.py index 7d4981e34..489ed0618 100644 --- a/bookwyrm/models/fields.py +++ b/bookwyrm/models/fields.py @@ -425,6 +425,10 @@ class ImageField(ActivitypubFieldMixin, models.ImageField): def field_to_activity(self, value, alt=None): url = self.get_absolute_url(value) + + if not url: + return None + return activitypub.Document(url=url, name=alt) def field_from_activity(self, value): @@ -465,7 +469,7 @@ class ImageField(ActivitypubFieldMixin, models.ImageField): def get_absolute_url(self, value): """returns an absolute URL for the image""" name = getattr(value, "name") - if name is None: + if not name: return None url = filepath_to_uri(name)