Fixes get_or_create error when multiple matching notifications exist

This commit is contained in:
Mouse Reeve 2022-07-09 12:29:47 -07:00
parent c092d952bd
commit f92b4548b1

View file

@ -71,7 +71,9 @@ class Notification(BookWyrmModel):
"""Create a notification"""
if related_user and (not user.local or user == related_user):
return
notification, _ = cls.objects.get_or_create(user=user, **kwargs)
notification = cls.objects.filter(user=user, **kwargs).first()
if not notification:
notification = cls.objects.create(user=user, **kwargs)
if related_user:
notification.related_users.add(related_user)
notification.read = False