Fixes status notifications

This commit is contained in:
Mouse Reeve 2021-02-10 15:18:20 -08:00
parent 74d39c3e24
commit 6f748a6a24
2 changed files with 6 additions and 2 deletions

View file

@ -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:

View file

@ -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,