-
Notifications
You must be signed in to change notification settings - Fork 8
refactor: 채팅방 생성 동기식으로 변경 #474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: 채팅방 생성 동기식으로 변경 #474
Conversation
Walkthrough
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Suggested reviewers
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 unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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/main/java/com/example/solidconnection/mentor/dto/MentoringConfirmResponse.java (1)
3-4: 2) chatRoomId 추가 및 NON_NULL 직렬화 처리 좋습니다
- 설명: 레코드 컴포넌트에 @JsonInclude(NON_NULL)을 국소 적용해 역호환을 유지했습니다. 팩토리 메서드도 명확합니다.
- 제안:
- 외부 API 스펙 문서에 chatRoomId 조건부 반환을 명시하세요.
- 필드 설명을 스웨거/스키마(@Schema)로 보강하면 클라이언트 이해도가 높아집니다.
API 문서에 승인 시 chatRoomId가 포함됨을 반영해 주시겠어요?
Also applies to: 9-12, 15-16
src/main/java/com/example/solidconnection/chat/service/ChatService.java (1)
177-181: 3) Optional 기반 조회로 null 분기 제거 및 가독성 개선
- 설명: 현재는 null 체크로 존재 유무를 판별합니다. Optional로 계약을 표현하면 의도가 선명해집니다.
- 제안: Repository를 Optional로 바꾼 뒤, 아래처럼 early-return을 간결화하세요.
- public Long createMentoringChatRoom(Long mentoringId, Long mentorId, Long menteeId) { - ChatRoom existingChatRoom = chatRoomRepository.findByMentoringId(mentoringId); - if (existingChatRoom != null) { - return existingChatRoom.getId(); - } + public Long createMentoringChatRoom(Long mentoringId, Long mentorId, Long menteeId) { + var existingId = chatRoomRepository.findByMentoringId(mentoringId) + .map(ChatRoom::getId) + .orElse(null); + if (existingId != null) { + return existingId; + }src/main/java/com/example/solidconnection/mentor/service/MentoringCommandService.java (1)
8-9: 5) 동기식 생성으로 목표 달성 확인 + 트랜잭션 경계 재검토 제안
설명: 승인 시 즉시 ChatService를 호출해 chatRoomId를 반환하는 흐름은 PR 목적에 부합합니다. 같은 트랜잭션에서 menteeCount 증가와 방 생성이 함께 롤백되는 점도 안전합니다.
제안:
- 동시 승인 레이스를 막기 위해 Mentoring 행을 비관적 잠금으로 조회하는 findById(PESSIMISTIC_WRITE) 도입을 고려하세요.
- ChatService에서 유니크 충돌 복구 로직을 적용했다면, 여기서는 현재 코드로 충분합니다.
참고: 파라미터로 전달하는 식별자는 SiteUser 기준이며 ChatParticipant와 스키마가 일치합니다. 네이밍도 명확합니다.
Also applies to: 29-29, 51-55, 57-58
src/test/java/com/example/solidconnection/mentor/service/MentoringCommandServiceTest.java (1)
137-137: 6) 순서 의존성 제거로 테스트 안정화
- 설명: participantIds 비교가 containsExactly를 사용해 컬렉션 순서에 의존합니다. JPA 컬렉션 순서는 매핑에 따라 달라질 수 있어 취약합니다.
- 제안: 순서 무관 비교로 변경하세요.
- assertAll( - () -> assertThat(afterChatRoom.isGroup()).isFalse(), - () -> assertThat(participantIds).containsExactly(mentorUser1.getId(), menteeUser.getId()), - () -> assertThat(response.chatRoomId()).isEqualTo(afterChatRoom.getId()) - ); + assertAll( + () -> assertThat(afterChatRoom.isGroup()).isFalse(), + () -> assertThat(participantIds) + .containsExactlyInAnyOrder(mentorUser1.getId(), menteeUser.getId()), + () -> assertThat(response.chatRoomId()).isEqualTo(afterChatRoom.getId()) + );Also applies to: 140-148
📜 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.
📒 Files selected for processing (7)
src/main/java/com/example/solidconnection/chat/repository/ChatRoomRepository.java(1 hunks)src/main/java/com/example/solidconnection/chat/service/ChatService.java(1 hunks)src/main/java/com/example/solidconnection/mentor/dto/MentoringApprovedEvent.java(0 hunks)src/main/java/com/example/solidconnection/mentor/dto/MentoringConfirmResponse.java(1 hunks)src/main/java/com/example/solidconnection/mentor/service/MentoringCommandService.java(3 hunks)src/main/java/com/example/solidconnection/mentor/service/MentoringEventHandler.java(0 hunks)src/test/java/com/example/solidconnection/mentor/service/MentoringCommandServiceTest.java(2 hunks)
💤 Files with no reviewable changes (2)
- src/main/java/com/example/solidconnection/mentor/service/MentoringEventHandler.java
- src/main/java/com/example/solidconnection/mentor/dto/MentoringApprovedEvent.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (1)
src/test/java/com/example/solidconnection/mentor/service/MentoringCommandServiceTest.java (1)
183-191: 7) 거절 플로우 검증 명확하고 충분합니다
- 설명: chatRoomId null과 방 미생성 보장을 함께 확인합니다. 반환 객체 기반의 즉시 검증으로 테스트가 간결해졌습니다.
관련 이슈
작업 내용
AS-IS
TO-BE
특이 사항
리뷰 요구사항 (선택)