From b9c2de751d9a30f7fbd60a7b2d946243e2acc7bd Mon Sep 17 00:00:00 2001 From: moanos Date: Sat, 3 Aug 2024 08:52:49 +0200 Subject: [PATCH] fix: Only trigger notification for subscribers that don't post the comment themeselves --- src/fellchensammlung/views.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/fellchensammlung/views.py b/src/fellchensammlung/views.py index 7c60b9e..719a10b 100644 --- a/src/fellchensammlung/views.py +++ b/src/fellchensammlung/views.py @@ -68,11 +68,13 @@ def adoption_notice_detail(request, adoption_notice_id): # Notify users that a comment was added for subscription in adoption_notice.get_subscriptions(): - notification = CommentNotification(user=subscription.user, - title=f"{adoption_notice.name} - Neuer Kommentar", - text=f"{request.user}: {comment_instance.text}", - comment=comment_instance) - notification.save() + # Create a notification but only if the user is not the one that posted the comment + if subscription.user != request.user: + notification = CommentNotification(user=subscription.user, + title=f"{adoption_notice.name} - Neuer Kommentar", + text=f"{request.user}: {comment_instance.text}", + comment=comment_instance) + notification.save() else: raise PermissionDenied else: