From fd844b2ccf05419a2245043d42adf434f3fa1cc2 Mon Sep 17 00:00:00 2001 From: ri-naa Date: Wed, 8 Jan 2025 02:51:45 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=8C=93=EA=B8=80,=20=EC=B1=84=ED=8C=85?= =?UTF-8?q?=20=EC=95=8C=EB=A6=BC=20=EB=8C=80=EC=83=81=20user=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/application/ChatService.java | 4 +++- .../comment/application/CommentService.java | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/on/server/domain/chat/application/ChatService.java b/src/main/java/com/on/server/domain/chat/application/ChatService.java index 7bcd1912..751876ac 100644 --- a/src/main/java/com/on/server/domain/chat/application/ChatService.java +++ b/src/main/java/com/on/server/domain/chat/application/ChatService.java @@ -347,7 +347,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); } diff --git a/src/main/java/com/on/server/domain/comment/application/CommentService.java b/src/main/java/com/on/server/domain/comment/application/CommentService.java index 66599e11..855b830e 100644 --- a/src/main/java/com/on/server/domain/comment/application/CommentService.java +++ b/src/main/java/com/on/server/domain/comment/application/CommentService.java @@ -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); } @@ -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); }