Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ private boolean isMemberVisible(Member member, Cat cat, Map<Member, Boolean> coP
return isStandBy || isNotParticipant;
}

public Optional<CoParent> getByCoParentId(Member participant, Long coParentId) {
return coParentRepository.findByParticipantAndId(participant, coParentId);
public Optional<CoParent> getByParticipantAndCoParentId(Member receiver, Long coParentId) {
return coParentRepository.findByParticipantAndId(receiver, coParentId)
.filter(CoParent::isStandBy);
}

public boolean isResponded(Long coParentId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
}

Expand All @@ -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> coParent = coParentService.getByCoParentId(receiver, coParentId);
private NotificationValidationResDTO validateCoParentByParticipant(Member receiver, Long coParentId) {
Optional<CoParent> coParent = coParentService.getByParticipantAndCoParentId(receiver, coParentId);

if (coParent.isEmpty()) {
return NotificationValidationResDTO.invalid(EnumErrorCode.CO_PARENT_NOT_FOUND.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Loading