Skip to content
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

Ignore: ✨ Receive Chatroom Detail Informations #188

Merged
merged 26 commits into from
Nov 2, 2024

Conversation

psychology50
Copy link
Member

작업 이유

  • Enable users to retrieve chatroom details (e.g., recent messages, participants, user info) upon accessing the chatroom.

작업 사항

1️⃣ Design

Data requirements:

  1. myInfo
  2. recentChatMessages
  3. recentParticipants
  4. otherParticipantIds

Since the participant list can reach a max of 300 users, sending all at once is impractical. To handle this, the server will first send recently active participants. The client can then request additional participant details as needed.


2️⃣ Reuqest & Response Specification

  • request
    • url: GET /v2/chat-rooms/{chatroom_id}
    • pre-condition: Authenticated User, Joined Chatroom
  • response
    image

3️⃣ Redis Chat Message Structure

Previously, we stored chat messages with a key format of chatroom:{chatroom_id}:message:{message_id} in a hash. Although message_id is unique and sortable, it didn’t ensure order when saving. By switching to a Sorted Set, we resolve issues around slicing chat history and counting unread messages.


4️⃣ DTO Naming

  • We need a response DTO, but ChatRoomRes.Detail already exists.
  • Maybe we can try to serialize with ignored fields in the original detail DTO. (Creation must be processed using a static factory method.)
    • This requires thorough testing, and exception handling is challenging since record types provide a public constructor by default.
// 1. View 중심의 네이밍
public final class ChatRoomRes {
    public record Summary(...) { }  // 목록 표시용 간단 정보
    public record Info(...) { }     // 기존 Detail을 Info로 변경 (기본 정보)
    public record View(...) { }     // 새로운 DTO (상세 페이지 전체 뷰)
}

// 2. 사용 목적 중심의 네이밍
public final class ChatRoomRes {
    public record Summary(...) { }           // 현재와 동일
    public record BasicDetail(...) { }       // 기존 Detail
    public record CompleteDetail(...) { }    // 새로운 DTO
}

// 3. 도메인 중심의 네이밍
public final class ChatRoomRes {
    public record Summary(...) { }                 // 현재와 동일
    public record RoomDetail(...) { }             // 기존 Detail (방 정보만)
    public record RoomWithParticipants(...) { }   // 새로운 DTO (방+참여자+메시지)
}
  • I selected the third solution among the three choices:
    • clarity of domain information
    • other developers can easily infer what information it contains
    • intuitive and straightforward documentation.

리뷰어가 중점적으로 확인해야 하는 부분

  • I think the client has the responsibility for sorting based on the user’s name, as the server initially fetches only partial data.
  • Is the hasty data send at first approach optimal?

발견한 이슈

  • Update the socket application image to reflect the revised chat message-saving strategy.
  • Add unread message count to chatroom search response.

@psychology50 psychology50 added the enhancement New feature or request label Nov 2, 2024
@psychology50 psychology50 self-assigned this Nov 2, 2024
@psychology50 psychology50 merged commit 4fb271b into dev Nov 2, 2024
1 check passed
@psychology50 psychology50 deleted the feat/PW-598-get-chatroom-detail branch November 2, 2024 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant