diff --git a/bookwyrm/activitypub/book.py b/bookwyrm/activitypub/book.py index 7615adcf7..538fa571e 100644 --- a/bookwyrm/activitypub/book.py +++ b/bookwyrm/activitypub/book.py @@ -11,6 +11,7 @@ class Book(ActivityObject): """ serializes an edition or work, abstract """ title: str + lastEditedBy: str = None sortTitle: str = "" subtitle: str = "" description: str = "" diff --git a/bookwyrm/models/activitypub_mixin.py b/bookwyrm/models/activitypub_mixin.py index f687e96cb..71e02082b 100644 --- a/bookwyrm/models/activitypub_mixin.py +++ b/bookwyrm/models/activitypub_mixin.py @@ -148,14 +148,14 @@ class ActivitypubMixin: mentions = self.recipients if hasattr(self, "recipients") else [] # we always send activities to explicitly mentioned users' inboxes - recipients = [u.inbox for u in mentions or []] + recipients = [u.inbox for u in mentions or [] if not u.local] # unless it's a dm, all the followers should receive the activity if privacy != "direct": # we will send this out to a subset of all remote users queryset = user_model.viewer_aware_objects(user).filter( local=False, - ) + ).distinct() # filter users first by whether they're using the desired software # this lets us send book updates only to other bw servers if software: @@ -175,7 +175,7 @@ class ActivitypubMixin: "inbox", flat=True ) recipients += list(shared_inboxes) + list(inboxes) - return recipients + return list(set(recipients)) def to_activity_dataclass(self): """ convert from a model to an activity """ diff --git a/bookwyrm/models/book.py b/bookwyrm/models/book.py index a6824c0ad..5280c7aaf 100644 --- a/bookwyrm/models/book.py +++ b/bookwyrm/models/book.py @@ -26,7 +26,11 @@ class BookDataModel(ObjectMixin, BookWyrmModel): max_length=255, blank=True, null=True, deduplication_field=True ) - last_edited_by = models.ForeignKey("User", on_delete=models.PROTECT, null=True) + last_edited_by = fields.ForeignKey( + "User", + on_delete=models.PROTECT, + null=True, + ) class Meta: """ can't initialize this model, that wouldn't make sense """