Merge pull request #1614 from bookwyrm-social/outbox-error

Safer call to get preview image or books
This commit is contained in:
Mouse Reeve 2021-11-15 13:47:00 -08:00 committed by GitHub
commit 2968145627
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -189,8 +189,10 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
if hasattr(activity, "name"):
activity.name = self.pure_name
activity.type = self.pure_type
books = [getattr(self, "book", None)] + list(self.mention_books.all())
if len(books) == 1 and books[0].preview_image:
book = getattr(self, "book", None)
books = [book] if book else []
books += list(self.mention_books.all())
if len(books) == 1 and getattr(books[0], "preview_image", None):
covers = [
activitypub.Document(
url=fields.get_absolute_url(books[0].preview_image),