Skip to content

채팅방 조회/메시지 전송/읽음 처리 API 구현 - #42

Merged
yoonjeonggg merged 1 commit into
mainfrom
feat/chat-room-service
Jun 15, 2026
Merged

yoonjeonggg merged 1 commit into
mainfrom
feat/chat-room-service

Conversation

@yoonjeonggg

@yoonjeonggg yoonjeonggg commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

Release Notes

  • New Features

    • Added chat room management endpoints: list your active rooms, view room details, and leave rooms
    • Added message retrieval with cursor-based pagination to view chat history
    • Added message sending capability supporting text and file attachments
    • Added read status tracking to monitor which messages you've read
  • Tests

    • Expanded test coverage for chat operations and workflows

@yoonjeonggg
yoonjeonggg merged commit dadc915 into main Jun 15, 2026
1 of 2 checks passed
@coderabbitai

coderabbitai Bot commented Jun 15, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 73f6e802-a479-4b0b-8031-b8b551dc9da2

📥 Commits

Reviewing files that changed from the base of the PR and between eda9a38 and 01d33cc.

📒 Files selected for processing (14)
  • src/main/java/chainsawman/gesture/controller/ChatRoomController.java
  • src/main/java/chainsawman/gesture/dto/chatRoom/request/ReadMarkRequest.java
  • src/main/java/chainsawman/gesture/dto/chatRoom/request/SendMessageRequest.java
  • src/main/java/chainsawman/gesture/dto/chatRoom/response/ChatMessageListResponse.java
  • src/main/java/chainsawman/gesture/dto/chatRoom/response/ChatMessageResponse.java
  • src/main/java/chainsawman/gesture/dto/chatRoom/response/ChatRoomDetailResponse.java
  • src/main/java/chainsawman/gesture/dto/chatRoom/response/ChatRoomListResponse.java
  • src/main/java/chainsawman/gesture/dto/chatRoom/response/ReadMarkResponse.java
  • src/main/java/chainsawman/gesture/entity/chat/ChatParticipant.java
  • src/main/java/chainsawman/gesture/exceptions/chat/ChatRoomNotParticipantException.java
  • src/main/java/chainsawman/gesture/repository/chat/ChatMessageRepository.java
  • src/main/java/chainsawman/gesture/repository/chat/ChatParticipantRepository.java
  • src/main/java/chainsawman/gesture/service/ChatRoomService.java
  • src/test/java/chainsawman/gesture/service/ChatRoomServiceTest.java

📝 Walkthrough

Walkthrough

Six new REST endpoints are added to ChatRoomController (list, detail, leave, paginated messages, send, read-mark). ChatParticipant gains a lastReadMessageIdx column, ChatRoomNotParticipantException is introduced, repository interfaces gain paged/existence/JPQL methods, all backing DTOs are created, ChatRoomService is expanded with six new methods plus a profile-image URL helper, and ChatRoomServiceTest is significantly extended with full scenario coverage.

Changes

Chat Room Operations

Layer / File(s) Summary
Entity field and participant exception
src/main/java/chainsawman/gesture/entity/chat/ChatParticipant.java, src/main/java/chainsawman/gesture/exceptions/chat/ChatRoomNotParticipantException.java
ChatParticipant gains a last_read_message_idx persistent column; ChatRoomNotParticipantException is added with FORBIDDEN/CHAT_004 and used as a guard across all new participant-checking paths.
Repository query methods
src/main/java/chainsawman/gesture/repository/chat/ChatMessageRepository.java, src/main/java/chainsawman/gesture/repository/chat/ChatParticipantRepository.java
ChatMessageRepository gets two paged descending finders and an existence check; ChatParticipantRepository gets derived finders, an existence check, a count method, a JOIN FETCH JPQL query, and a grouped-count JPQL query.
Request and response DTOs
src/main/java/chainsawman/gesture/dto/chatRoom/request/..., src/main/java/chainsawman/gesture/dto/chatRoom/response/...
Adds SendMessageRequest, ReadMarkRequest, ChatRoomListResponse, ChatRoomDetailResponse (with nested ParticipantInfo), ChatMessageResponse (with nested SenderInfo and deleted-message null logic), ChatMessageListResponse, and ReadMarkResponse—all using Lombok and Jackson.
Service methods
src/main/java/chainsawman/gesture/service/ChatRoomService.java
Adds getMyChatRooms, getChatRoomDetail, leaveChatRoom, getMessages (cursor pagination + URL enrichment), markAsRead (existence validation + state update), sendMessage (optional media UUID lookup), and the private buildProfileImageUrlMap helper; wires in ChatMessageRepository and MediaRepository.
REST endpoints
src/main/java/chainsawman/gesture/controller/ChatRoomController.java
Six new controller handlers covering GET /chat-rooms, GET/DELETE /chat-rooms/{idx}, GET/POST /chat-rooms/{idx}/messages, and PATCH /chat-rooms/{idx}/read with @Valid request body validation.
Service test coverage
src/test/java/chainsawman/gesture/service/ChatRoomServiceTest.java
Adds mocks for ChatMessageRepository and MediaRepository, extended setUp, and test suites for all six new service methods including cursor edge cases, deleted-message nullification, read-mark overwrite, and MediaNotFoundException.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ChatRoomController
  participant ChatRoomService
  participant ChatParticipantRepository
  participant ChatMessageRepository
  participant MediaRepository

  rect rgba(70, 130, 180, 0.5)
    note over Client, ChatParticipantRepository: GET /chat-rooms
    Client->>ChatRoomController: GET /chat-rooms
    ChatRoomController->>ChatRoomService: getMyChatRooms()
    ChatRoomService->>ChatParticipantRepository: findByUser_IdxWithChatRoom(userIdx)
    ChatRoomService->>ChatParticipantRepository: countByChatRoomIdxIn(roomIds)
    ChatRoomService-->>Client: List~ChatRoomListResponse~
  end

  rect rgba(60, 179, 113, 0.5)
    note over Client, MediaRepository: GET /chat-rooms/{idx}/messages
    Client->>ChatRoomController: GET /chat-rooms/{idx}/messages?cursor&size
    ChatRoomController->>ChatRoomService: getMessages(roomIdx, cursor, size)
    ChatRoomService->>ChatParticipantRepository: existsByChatRoom_IdxAndUser_Idx
    ChatRoomService->>ChatMessageRepository: findByChatRoom_IdxAndIdxLessThanOrderByIdxDesc (or no-cursor variant)
    ChatRoomService->>MediaRepository: resolve file URLs per message
    ChatRoomService-->>Client: ChatMessageListResponse (hasNext, nextCursor, messages)
  end

  rect rgba(210, 105, 30, 0.5)
    note over Client, ChatMessageRepository: POST /chat-rooms/{idx}/messages
    Client->>ChatRoomController: POST /chat-rooms/{idx}/messages (SendMessageRequest)
    ChatRoomController->>ChatRoomService: sendMessage(roomIdx, request)
    ChatRoomService->>ChatParticipantRepository: existsByChatRoom_IdxAndUser_Idx
    ChatRoomService->>MediaRepository: lookup by fileUuid (if FILE type)
    ChatRoomService-->>Client: ChatMessageResponse
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐇 Hop, hop! New rooms to list and roam,
Cursors page through messages like foam,
Read marks saved, the rabbit cheers,
Leave a room with no more fears.
Six endpoints built, the tests all pass—
This chat feature's ready at last! 🌿

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/chat-room-service

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant