forked from mirrors/bookwyrm
Fixes status notifications
This commit is contained in:
parent
74d39c3e24
commit
6f748a6a24
2 changed files with 6 additions and 2 deletions
|
@ -263,6 +263,7 @@ class ManyToManyField(ActivitypubFieldMixin, models.ManyToManyField):
|
||||||
if formatted is None or formatted is MISSING:
|
if formatted is None or formatted is MISSING:
|
||||||
return
|
return
|
||||||
getattr(instance, self.name).set(formatted)
|
getattr(instance, self.name).set(formatted)
|
||||||
|
instance.save(broadcast=False)
|
||||||
|
|
||||||
def field_to_activity(self, value):
|
def field_to_activity(self, value):
|
||||||
if self.link_only:
|
if self.link_only:
|
||||||
|
|
|
@ -52,13 +52,15 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
|
||||||
serialize_reverse_fields = [('attachments', 'attachment', 'id')]
|
serialize_reverse_fields = [('attachments', 'attachment', 'id')]
|
||||||
deserialize_reverse_fields = [('attachments', 'attachment')]
|
deserialize_reverse_fields = [('attachments', 'attachment')]
|
||||||
|
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
''' save and notify '''
|
''' save and notify '''
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
notification_model = apps.get_model(
|
notification_model = apps.get_model(
|
||||||
'bookwyrm.Notification', require_ready=True)
|
'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(
|
notification_model.objects.create(
|
||||||
user=self.reply_parent.user,
|
user=self.reply_parent.user,
|
||||||
notification_type='REPLY',
|
notification_type='REPLY',
|
||||||
|
@ -68,7 +70,8 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
|
||||||
for mention_user in self.mention_users.all():
|
for mention_user in self.mention_users.all():
|
||||||
# avoid double-notifying about this status
|
# avoid double-notifying about this status
|
||||||
if not mention_user.local or notification_model.objects.filter(
|
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
|
continue
|
||||||
notification_model.objects.create(
|
notification_model.objects.create(
|
||||||
user=mention_user,
|
user=mention_user,
|
||||||
|
|
Loading…
Reference in a new issue