From 953b3371b3fd027aea6bd8a8f52d1557b605461f Mon Sep 17 00:00:00 2001 From: becooq81 Date: Mon, 15 Jul 2024 17:51:31 +0900 Subject: [PATCH] fix: remove unnecessary code --- .../notification/controller/NotificationController.java | 3 +++ .../api/notification/service/NotificationService.java | 8 -------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/poolc/api/notification/controller/NotificationController.java b/src/main/java/org/poolc/api/notification/controller/NotificationController.java index be2f393e..1dc6c3b4 100644 --- a/src/main/java/org/poolc/api/notification/controller/NotificationController.java +++ b/src/main/java/org/poolc/api/notification/controller/NotificationController.java @@ -24,6 +24,9 @@ public class NotificationController { @GetMapping("/unread") public ResponseEntity> getUnreadNotifications(@AuthenticationPrincipal Member member) { List notifications = notificationService.getUnreadNotificationsForMember(member.getLoginID()); + if (notifications.isEmpty()) { + return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); + } List responses = notifications.stream() .map(NotificationResponse::of) .collect(Collectors.toList()); diff --git a/src/main/java/org/poolc/api/notification/service/NotificationService.java b/src/main/java/org/poolc/api/notification/service/NotificationService.java index 618dc4fc..e3e9aa4c 100644 --- a/src/main/java/org/poolc/api/notification/service/NotificationService.java +++ b/src/main/java/org/poolc/api/notification/service/NotificationService.java @@ -46,14 +46,6 @@ public List getAllNotificationsForMember(String receiverId) { .sorted(Comparator.comparing(Notification::getCreatedAt).reversed()) .collect(Collectors.toList()); - if (!notifications.isEmpty()) { - notifications.forEach(notification -> { - if (notification != null) { - notification.memberReads(); - } - }); - } - Member recipient = getMemberByLoginID(receiverId); if (recipient == null) { throw new IllegalArgumentException("Recipient not found for the given receiverId");