From f92b4548b188267a10b64ae78aa767fe8644a46c Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 9 Jul 2022 12:29:47 -0700 Subject: [PATCH] Fixes get_or_create error when multiple matching notifications exist --- bookwyrm/models/notification.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bookwyrm/models/notification.py b/bookwyrm/models/notification.py index 818c7bd05..921174924 100644 --- a/bookwyrm/models/notification.py +++ b/bookwyrm/models/notification.py @@ -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