Skip to content

Commit

Permalink
Merge pull request #126 from UMC-ON/feat/alert
Browse files Browse the repository at this point in the history
fix: 댓글, 채팅 알림 대상 user 로직 수정
  • Loading branch information
ri-naa authored Jan 7, 2025
2 parents 3a3df69 + 84bfdf3 commit 2252b4d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,9 @@ public void postMessage(User user, Long roomId, String message) {
alertType = AlertType.COMPANY_CHAT;
}

User alertUser = user != currentChattingRoom.getChatUserOne() ? currentChattingRoom.getChatUserOne() : currentChattingRoom.getChatUserTwo();
User alertUser = user.equals(currentChattingRoom.getChatUserOne())
? currentChattingRoom.getChatUserTwo()
: currentChattingRoom.getChatUserOne();

alertService.sendAndSaveAlert(alertUser, alertType, title, body, roomId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ public CommentResponseDTO createComment(Long postId, CommentRequestDTO commentRe
}
String body = commentRequestDTO.getContents();

alertService.sendAndSaveAlert(post.getUser(), alertType, title, body, post.getId());
// 게시글 작성자와 댓글 작성자 다를 경우에만 알림 전송
// 본인이 쓴 게시물에 댓글 작성 시 알림 전송 x
if(!user.equals(post.getUser())){
alertService.sendAndSaveAlert(post.getUser(), alertType, title, body, post.getId());
}

return CommentResponseDTO.from(comment, commentRepository);
}
Expand Down Expand Up @@ -143,7 +147,14 @@ public CommentResponseDTO createReply(Long parentCommentId, CommentRequestDTO co
String title = "새로운 대댓글이 달렸어요.";
String body = commentRequestDTO.getContents();

alertService.sendAndSaveAlert(post.getUser(), alertType, title, body, post.getId());
// 대댓글 작성자가 부모댓글, 게시글 댓글 작성자가 아닐 경우에만 알림 보내기
// 대댓글 작성자 = user, 부모댓글 작성자 = parentComment.getUser(), 게시글 작성자 = post.getUser()
if (!user.equals(parentComment.getUser())) {
alertService.sendAndSaveAlert(parentComment.getUser(), alertType, title, body, post.getId());
}
else if (!user.equals(post.getUser())) {
alertService.sendAndSaveAlert(post.getUser(), alertType, title, body, post.getId());
}

return CommentResponseDTO.from(reply, commentRepository);
}
Expand Down

0 comments on commit 2252b4d

Please sign in to comment.