Skip to content

Commit

Permalink
[FIX] 부모 자식 관계에 1명만 참여하고 있을 때도 답변할 수 있도록 변경 #130
Browse files Browse the repository at this point in the history
  • Loading branch information
ddongseop committed Feb 27, 2024
1 parent 3e65260 commit 4fa5a62
Showing 1 changed file with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,30 @@ public void answerTodayQuestion(Long userId, TodayAnswerRequestDto request) {
User myUser = getUserById(userId);
Parentchild parentchild = getParentchildByUser(myUser);
QnA todayQnA = getTodayQnAByParentchild(parentchild);
User opponentUser = getOpponentByParentchild(parentchild, userId);

if (myUser.isMeChild()) {
todayQnA.saveChildAnswer(request.getAnswer());
notificationService.pushOpponentReply(todayQnA.getQuestion().getChildQuestion(), opponentUser.getId());
// fcmService.pushOpponentReply(todayQnA.getQuestion().getChildQuestion(), opponentUser.getId());
List<User> opponentUserList = userRepository.findUserByParentChild(parentchild)
.stream()
.filter(user -> !user.getId().equals(userId))
.collect(Collectors.toList());

if (opponentUserList.isEmpty()) {
if (myUser.isMeChild()) {
todayQnA.saveChildAnswer(request.getAnswer());
} else {
todayQnA.saveParentAnswer(request.getAnswer());
}
} else {
todayQnA.saveParentAnswer(request.getAnswer());
notificationService.pushOpponentReply(todayQnA.getQuestion().getParentQuestion(), opponentUser.getId());
User opponentUser = opponentUserList.get(0);

if (myUser.isMeChild()) {
todayQnA.saveChildAnswer(request.getAnswer());
notificationService.pushOpponentReply(todayQnA.getQuestion().getChildQuestion(), opponentUser.getId());
// fcmService.pushOpponentReply(todayQnA.getQuestion().getChildQuestion(), opponentUser.getId());
} else {
todayQnA.saveParentAnswer(request.getAnswer());
notificationService.pushOpponentReply(todayQnA.getQuestion().getParentQuestion(), opponentUser.getId());
// fcmService.pushOpponentReply(todayQnA.getQuestion().getParentQuestion(), opponentUser.getId());
}
}
}

Expand Down

0 comments on commit 4fa5a62

Please sign in to comment.