1
0
Fork 0

Updates group leave and remove notifications

This commit is contained in:
Mouse Reeve 2022-07-05 13:05:01 -07:00
parent c65381adf9
commit 736d29ea20
5 changed files with 28 additions and 21 deletions

View file

@ -57,10 +57,11 @@ class Notification(BookWyrmModel):
@transaction.atomic
def notify(cls, user, related_user, **kwargs):
"""Create a notification"""
if not user.local or user == related_user:
if related_user and (not user.local or user == related_user):
return
notification, _ = cls.objects.get_or_create(user=user, **kwargs)
notification.related_users.add(related_user)
if related_user:
notification.related_users.add(related_user)
notification.read = False
notification.save()