diff --git a/meowzip-api-server/src/main/java/com/meowzip/apiserver/cat/service/CoParentService.java b/meowzip-api-server/src/main/java/com/meowzip/apiserver/cat/service/CoParentService.java index 52ba995..1b56b67 100644 --- a/meowzip-api-server/src/main/java/com/meowzip/apiserver/cat/service/CoParentService.java +++ b/meowzip-api-server/src/main/java/com/meowzip/apiserver/cat/service/CoParentService.java @@ -69,8 +69,9 @@ private boolean isMemberVisible(Member member, Cat cat, Map coP return isStandBy || isNotParticipant; } - public Optional getByCoParentId(Member participant, Long coParentId) { - return coParentRepository.findByParticipantAndId(participant, coParentId); + public Optional getByParticipantAndCoParentId(Member receiver, Long coParentId) { + return coParentRepository.findByParticipantAndId(receiver, coParentId) + .filter(CoParent::isStandBy); } public boolean isResponded(Long coParentId) { diff --git a/meowzip-api-server/src/main/java/com/meowzip/apiserver/notification/service/NotificationService.java b/meowzip-api-server/src/main/java/com/meowzip/apiserver/notification/service/NotificationService.java index 84b1c60..0b9f065 100644 --- a/meowzip-api-server/src/main/java/com/meowzip/apiserver/notification/service/NotificationService.java +++ b/meowzip-api-server/src/main/java/com/meowzip/apiserver/notification/service/NotificationService.java @@ -60,14 +60,15 @@ public NotificationValidationResDTO validateNotification(Member receiver, Long n .orElseThrow(() -> new ClientException.NotFound(EnumErrorCode.NOTIFICATION_HISTORY_NOT_FOUND)); Long contentId = notification.getDetailLink(); - if (contentId == null) { + if (!notification.isCoParentResponseNotification() && contentId == null) { return NotificationValidationResDTO.invalid(EnumErrorCode.BAD_REQUEST.getMessage()); } return switch (notification.getTemplate().getCode()) { case MN001, MN002 -> validateCommunityPost(contentId); case MN003 -> validateDiary(contentId); - case MN004, MN005, MN006 -> validateCoParent(notification.getReceiver(), contentId); + case MN004 -> validateCoParentByParticipant(notification.getReceiver(), contentId); + case MN005, MN006 -> NotificationValidationResDTO.valid(); }; } @@ -83,8 +84,8 @@ private NotificationValidationResDTO validateDiary(Long diaryId) { : NotificationValidationResDTO.invalid(EnumErrorCode.DIARY_NOT_FOUND.getMessage()); } - private NotificationValidationResDTO validateCoParent(Member receiver, Long coParentId) { - Optional coParent = coParentService.getByCoParentId(receiver, coParentId); + private NotificationValidationResDTO validateCoParentByParticipant(Member receiver, Long coParentId) { + Optional coParent = coParentService.getByParticipantAndCoParentId(receiver, coParentId); if (coParent.isEmpty()) { return NotificationValidationResDTO.invalid(EnumErrorCode.CO_PARENT_NOT_FOUND.getMessage()); diff --git a/meowzip-core/src/main/java/com/meowzip/notification/entity/NotificationHistory.java b/meowzip-core/src/main/java/com/meowzip/notification/entity/NotificationHistory.java index e0da696..0b97153 100644 --- a/meowzip-core/src/main/java/com/meowzip/notification/entity/NotificationHistory.java +++ b/meowzip-core/src/main/java/com/meowzip/notification/entity/NotificationHistory.java @@ -68,4 +68,9 @@ public String getType() { public String getPushBody() { return this.senderNickname + this.getTitle(); } + + public boolean isCoParentResponseNotification() { + return this.template.getCode() == NotificationCode.MN005 + || this.template.getCode() == NotificationCode.MN006; + } }