Skip to content

Conversation

@Gyuhyeok99
Copy link
Contributor

@Gyuhyeok99 Gyuhyeok99 commented Aug 15, 2025

관련 이슈

작업 내용

스크린샷 2025-08-15 오후 8 44 26

만욱님께서 요청해주신 기능을 구현한 pr입니다.

bruno 관련

특이 사항

리뷰 요구사항 (선택)

@coderabbitai
Copy link

coderabbitai bot commented Aug 15, 2025

Walkthrough

  1. ChatController: GET 엔드포인트 추가로 특정 room의 채팅 파트너 조회를 제공하며, ChatParticipantResponse를 200 OK로 반환.
  2. ChatService: public 메서드 getChatPartner(siteUserId, roomId) 추가. room 조회, 파트너 식별(findPartner), 사용자 로드, 예외 처리 후 ChatParticipantResponse 생성 반환. findPartner 위치 이동(로직 변경 없음).
  3. ChatServiceTest: ChatParticipantResponse import 추가 및 채팅방 파트너 정보 조회 테스트 추가. 동일한 중첩 테스트 블록이 중복으로 포함됨.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • nayonsoso
  • wibaek
  • lsy1307
  • whqtker

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (4)
src/test/java/com/example/solidconnection/chat/service/ChatServiceTest.java (1)

313-334: 3) 보안/권한 검증 경로의 테스트도 추가해 주세요.
성공 케이스는 좋습니다만, 비참여자 접근 차단 및 그룹방 예외 등 실패 경로를 함께 검증하면 회귀를 방지할 수 있습니다.

  • 제안: 아래 두 케이스를 같은 Nested 블록에 추가해 주세요.
    1. 비참여자가 파트너 조회 시도 시 CHAT_PARTICIPANT_NOT_FOUND 예외
    2. 그룹 채팅방에서 파트너 조회 시 INVALID_CHAT_ROOM_STATE 예외

적용 diff 예시:

     @Nested
     class 채팅방_파트너_정보를_조회한다 {

         @Test
         void 채팅방_파트너를_정상_조회한다() {
             // given
             ChatRoom chatRoom = chatRoomFixture.채팅방(false);
             chatParticipantFixture.참여자(user.getId(), chatRoom);
             chatParticipantFixture.참여자(mentor1.getId(), chatRoom);

             // when
             ChatParticipantResponse response = chatService.getChatPartner(user.getId(), chatRoom.getId());

             // then
             assertAll(
                     () -> assertThat(response.partnerId()).isEqualTo(mentor1.getId()),
                     () -> assertThat(response.nickname()).isEqualTo(mentor1.getNickname()),
                     () -> assertThat(response.profileUrl()).isEqualTo(mentor1.getProfileImageUrl())
             );
         }
+
+        @Test
+        void 비참여자는_파트너를_조회할_수_없다() {
+            // given
+            ChatRoom chatRoom = chatRoomFixture.채팅방(false);
+            chatParticipantFixture.참여자(user.getId(), chatRoom);
+            chatParticipantFixture.참여자(mentor1.getId(), chatRoom);
+
+            // when & then
+            assertThatCode(() -> chatService.getChatPartner(mentor2.getId(), chatRoom.getId()))
+                    .isInstanceOf(CustomException.class)
+                    .hasMessage(CHAT_PARTICIPANT_NOT_FOUND.getMessage());
+        }
+
+        @Test
+        void 그룹_채팅방에서는_예외가_발생한다() {
+            // given
+            ChatRoom groupRoom = chatRoomFixture.채팅방(true);
+            chatParticipantFixture.참여자(user.getId(), groupRoom);
+            chatParticipantFixture.참여자(mentor1.getId(), groupRoom);
+            chatParticipantFixture.참여자(mentor2.getId(), groupRoom);
+
+            // when & then
+            assertThatCode(() -> chatService.getChatPartner(user.getId(), groupRoom.getId()))
+                    .isInstanceOf(CustomException.class)
+                    .hasMessage(INVALID_CHAT_ROOM_STATE.getMessage());
+        }
     }

원하시면 위 테스트 추가분을 포함해 PR에 맞춰 전체 테스트 정리본을 드릴게요.

src/main/java/com/example/solidconnection/chat/controller/ChatController.java (1)

45-52: 3) (선택) roomId 타입을 long으로 정규화하면 일관성이 좋아집니다.
동일 컨트롤러의 다른 메서드들과 파라미터 타입 일관성 유지에 도움이 됩니다.

-    public ResponseEntity<ChatParticipantResponse> getChatPartner(
-            @AuthorizedUser long siteUserId,
-            @PathVariable("room-id") Long roomId
-    ) {
+    public ResponseEntity<ChatParticipantResponse> getChatPartner(
+            @AuthorizedUser long siteUserId,
+            @PathVariable("room-id") long roomId
+    ) {
src/main/java/com/example/solidconnection/chat/service/ChatService.java (2)

110-118: 2) (선택) findPartner 내부에 ‘요청자 참여 여부’ 체크를 포함하면 응집도가 높아집니다.
대안으로, findPartner가 그룹 예외뿐 아니라 비참여자 접근도 즉시 차단하게 만들면 호출부 실수를 방지할 수 있습니다.

 private ChatParticipant findPartner(ChatRoom chatRoom, long siteUserId) {
     if (chatRoom.isGroup()) {
         throw new CustomException(INVALID_CHAT_ROOM_STATE);
     }
+    boolean isMember = chatRoom.getChatParticipants().stream()
+            .anyMatch(participant -> participant.getSiteUserId() == siteUserId);
+    if (!isMember) {
+        throw new CustomException(CHAT_PARTICIPANT_NOT_FOUND);
+    }
     return chatRoom.getChatParticipants().stream()
             .filter(participant -> participant.getSiteUserId() != siteUserId)
             .findFirst()
             .orElseThrow(() -> new CustomException(CHAT_PARTNER_NOT_FOUND));
 }

100-101: 3) (선택) roomId를 long으로 변경해 메서드 시그니처 일관성을 높여주세요.
동일 클래스 내 다른 메서드(getChatMessages, markChatMessagesAsRead 등)는 원시 타입(long)을 사용합니다.

-    public ChatParticipantResponse getChatPartner(long siteUserId, Long roomId) {
+    public ChatParticipantResponse getChatPartner(long siteUserId, long roomId) {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 151c9ad and ff5073b.

📒 Files selected for processing (3)
  • src/main/java/com/example/solidconnection/chat/controller/ChatController.java (2 hunks)
  • src/main/java/com/example/solidconnection/chat/service/ChatService.java (1 hunks)
  • src/test/java/com/example/solidconnection/chat/service/ChatServiceTest.java (2 hunks)
🔇 Additional comments (4)
src/test/java/com/example/solidconnection/chat/service/ChatServiceTest.java (2)

17-17: 1) ChatParticipantResponse 임포트 추가, 잘 연결되었습니다.
한 문장으로 요약하면, 서비스/컨트롤러 변경과 테스트 타입이 일치해 좋습니다.


313-334: 2) 파트너 정보 정상 조회 테스트 케이스, 시나리오 적합합니다.
성공 경로를 실제 도메인 흐름(1:1 방, 두 명 참여자, 요청자 기준 파트너 도출)으로 검증해 신뢰도를 높입니다.

src/main/java/com/example/solidconnection/chat/controller/ChatController.java (2)

4-4: 1) 컨트롤러에서 DTO 임포트 경로 일관성 유지, 좋습니다.
서비스/컨트롤러가 동일한 DTO 패키지를 사용해 타입 충돌 여지가 없습니다.


45-52: 2) 엔드포인트 경로에 선행 슬래시 누락 — 실제 매핑이 깨집니다.
현재 @GetMapping("rooms/{room-id}/partner")는 클래스 레벨 "/chats"와 문자열 결합되어 "/chatsrooms/{room-id}/partner"로 매핑될 수 있습니다.

  • 수정안: 선행 슬래시를 추가해 "/chats/rooms/{room-id}/partner"가 되도록 고쳐주세요.
-    @GetMapping("rooms/{room-id}/partner")
+    @GetMapping("/rooms/{room-id}/partner")
     public ResponseEntity<ChatParticipantResponse> getChatPartner(
             @AuthorizedUser long siteUserId,
             @PathVariable("room-id") Long roomId
     ) {
         ChatParticipantResponse response = chatService.getChatPartner(siteUserId, roomId);
         return ResponseEntity.ok(response);
     }

Likely an incorrect or invalid review comment.

Copy link
Member

@whqtker whqtker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋습니다 ! 빠른 반영 감사합니다 👏

@Gyuhyeok99 Gyuhyeok99 merged commit afe27ab into solid-connection:develop Aug 16, 2025
2 checks passed
@Gyuhyeok99 Gyuhyeok99 deleted the feat/456-chatroom-partner-info branch August 24, 2025 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: 채팅방 partner 정보를 조회하는 API 추가

2 participants