Delete notifications when posts or comments are removed

This commit is contained in:
Tim
2025-07-14 01:00:17 +08:00
parent d6e4e93d59
commit df60850c5b
2 changed files with 2 additions and 2 deletions

View File

@@ -143,7 +143,7 @@ public class CommentService {
}
reactionRepository.findByComment(comment).forEach(reactionRepository::delete);
commentSubscriptionRepository.findByComment(comment).forEach(commentSubscriptionRepository::delete);
notificationRepository.findByComment(comment).forEach(n -> { n.setComment(null); notificationRepository.save(n); });
notificationRepository.deleteAll(notificationRepository.findByComment(comment));
commentRepository.delete(comment);
}
}

View File

@@ -353,7 +353,7 @@ public class PostService {
}
reactionRepository.findByPost(post).forEach(reactionRepository::delete);
postSubscriptionRepository.findByPost(post).forEach(postSubscriptionRepository::delete);
notificationRepository.findByPost(post).forEach(n -> { n.setPost(null); notificationRepository.save(n); });
notificationRepository.deleteAll(notificationRepository.findByPost(post));
postRepository.delete(post);
}