fix: Only trigger notification for subscribers that don't post the comment themeselves

This commit is contained in:
moanos [he/him] 2024-08-03 08:52:49 +02:00
parent 07aa165115
commit b9c2de751d

View File

@ -68,11 +68,13 @@ def adoption_notice_detail(request, adoption_notice_id):
# Notify users that a comment was added # Notify users that a comment was added
for subscription in adoption_notice.get_subscriptions(): for subscription in adoption_notice.get_subscriptions():
notification = CommentNotification(user=subscription.user, # Create a notification but only if the user is not the one that posted the comment
title=f"{adoption_notice.name} - Neuer Kommentar", if subscription.user != request.user:
text=f"{request.user}: {comment_instance.text}", notification = CommentNotification(user=subscription.user,
comment=comment_instance) title=f"{adoption_notice.name} - Neuer Kommentar",
notification.save() text=f"{request.user}: {comment_instance.text}",
comment=comment_instance)
notification.save()
else: else:
raise PermissionDenied raise PermissionDenied
else: else: