Merge pull request #190 from nagisa77/codex/remove-notifications-when-deleting-articles

Clean up notifications when posts or comments are removed
This commit is contained in:
Tim
2025-07-14 01:00:27 +08:00
committed by GitHub
2 changed files with 2 additions and 2 deletions
@@ -143,7 +143,7 @@ public class CommentService {
} }
reactionRepository.findByComment(comment).forEach(reactionRepository::delete); reactionRepository.findByComment(comment).forEach(reactionRepository::delete);
commentSubscriptionRepository.findByComment(comment).forEach(commentSubscriptionRepository::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); commentRepository.delete(comment);
} }
} }
@@ -353,7 +353,7 @@ public class PostService {
} }
reactionRepository.findByPost(post).forEach(reactionRepository::delete); reactionRepository.findByPost(post).forEach(reactionRepository::delete);
postSubscriptionRepository.findByPost(post).forEach(postSubscriptionRepository::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); postRepository.delete(post);
} }