mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-28 17:10:48 +08:00
Deduplicate post view notifications
This commit is contained in:
@@ -18,4 +18,6 @@ public interface NotificationRepository extends JpaRepository<Notification, Long
|
||||
List<Notification> findByComment(Comment comment);
|
||||
|
||||
void deleteByTypeAndFromUser(NotificationType type, User fromUser);
|
||||
|
||||
void deleteByUserAndTypeAndPostAndFromUser(User user, NotificationType type, Post post, User fromUser);
|
||||
}
|
||||
|
||||
@@ -58,6 +58,9 @@ public class NotificationService {
|
||||
|
||||
public Notification createNotification(User user, NotificationType type, Post post, Comment comment, Boolean approved,
|
||||
User fromUser, ReactionType reactionType, String content) {
|
||||
if (type == NotificationType.POST_VIEWED && post != null) {
|
||||
notificationRepository.deleteByUserAndTypeAndPostAndFromUser(user, type, post, fromUser);
|
||||
}
|
||||
Notification n = new Notification();
|
||||
n.setUser(user);
|
||||
n.setType(type);
|
||||
|
||||
Reference in New Issue
Block a user