From 6f748a6a2473ce84413616a745aae8d909f9eadc Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 10 Feb 2021 15:18:20 -0800 Subject: [PATCH] Fixes status notifications --- bookwyrm/models/fields.py | 1 + bookwyrm/models/status.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bookwyrm/models/fields.py b/bookwyrm/models/fields.py index bc10156b..55de1fab 100644 --- a/bookwyrm/models/fields.py +++ b/bookwyrm/models/fields.py @@ -263,6 +263,7 @@ class ManyToManyField(ActivitypubFieldMixin, models.ManyToManyField): if formatted is None or formatted is MISSING: return getattr(instance, self.name).set(formatted) + instance.save(broadcast=False) def field_to_activity(self, value): if self.link_only: diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index 7091fd0b..d2768e28 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -52,13 +52,15 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel): serialize_reverse_fields = [('attachments', 'attachment', 'id')] deserialize_reverse_fields = [('attachments', 'attachment')] + def save(self, *args, **kwargs): ''' save and notify ''' super().save(*args, **kwargs) notification_model = apps.get_model( 'bookwyrm.Notification', require_ready=True) - if self.reply_parent and self.reply_parent.user.local: + if self.reply_parent and self.reply_parent.user != self.user and \ + self.reply_parent.user.local: notification_model.objects.create( user=self.reply_parent.user, notification_type='REPLY', @@ -68,7 +70,8 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel): for mention_user in self.mention_users.all(): # avoid double-notifying about this status if not mention_user.local or notification_model.objects.filter( - related_status=self, related_user=mention_user).exists(): + user=mention_user, related_status=self, + related_user=self.user).exists(): continue notification_model.objects.create( user=mention_user,