Prevent error on serializing book cover

This commit is contained in:
Mouse Reeve
2020-10-31 10:50:00 -07:00
parent b8e9f90138
commit 2cdd281e98
2 changed files with 4 additions and 2 deletions

View File

@ -61,6 +61,8 @@ class Book(ActivitypubMixin, BookWyrmModel):
@property
def ap_cover(self):
''' an image attachment '''
if not self.cover or not hasattr(self.cover, 'url'):
return []
return [activitypub.Image(
url='https://%s%s' % (DOMAIN, self.cover.url),
)]