Skip to content

Conversation

@bo-ram-bo-ram
Copy link
Member

@bo-ram-bo-ram bo-ram-bo-ram commented Feb 20, 2025

Pull request

Related issue

resolve #225

Motivation and context

  • 히스토리 서버에서 채널별 과거 채팅 조회 api를 구현했습니다.
  • 페이징 기능을 포함하였습니다.
    • hasNext 여부를 반환하는 구조를 설계했습니다.
    • 첫 요청 시 cursorId 없이 요청할 수 있도록 처리하였고 이때 마지막 읽은 시점부터 조회할 수 있도록 하였습니다.

Solution

  • 채널 내 채팅 메시지 조회 API 구현

    • cursorId가 있는 경우: 해당 cursorId 이후의 메시지를 조회
    • cursorId가 없는 경우 (첫 요청): userChannelRepository에서 마지막 읽은 메시지(lastReadId)를 조회하여, 해당 ID 다음부터 메시지를 가져옴
      • 이때 lastReadId가 없는 경우 (채널에 첫 입장 시): 빈 응답 반환
  • 페이징 기능 및 hasNext 구현

    • 요청한 size보다 1개 더 많은 메시지를 가져와서, 다음 페이지가 있는지(hasNext) 확인
    • size + 1의 크기가 size보다 크면 hasNext = true 반환 후, 마지막 메시지는 응답에서 제외
    • @RequestParam(defaultValue = "30")를 사용하여 기본 페이지 크기를 30으로 설정
  • 마지막 메시지의 ID 반환

    • 응답 데이터에 마지막 메시지의 threadId를 포함하여, 클라이언트에서 이후 메시지를 조회할 때 cursorId로 활용 가능

How has this been tested

  • cursorId 없을 경우 => 마지막 읽은 id 값으로 조회
    스크린샷 2025-02-20 오후 9 08 34

  • cursorId 있을 경우

    • 이후 데이터가 size보다 더 있을 경우 : hasNext true, 데이터 size만큼 반환
      스크린샷 2025-02-20 오후 9 10 41
    • 이후 데이터가 size보다 더 없을 경우 : hasNext false, 남은 만큼
      스크린샷 2025-02-20 오후 9 13 12

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the docs/CONTRIBUTING.md document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@bo-ram-bo-ram bo-ram-bo-ram added ✨ Feature 기능 추가 🎮 BE 백엔드 무조건 스프린트내에 해야하는 것들 labels Feb 20, 2025
@bo-ram-bo-ram bo-ram-bo-ram self-assigned this Feb 20, 2025
@sgdevcamp2025 sgdevcamp2025 deleted a comment from netlify bot Feb 21, 2025
Copy link
Member

@mirlee0304 mirlee0304 left a comment

Choose a reason for hiding this comment

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

깔끔한 주석 감사합니다~

@bo-ram-bo-ram bo-ram-bo-ram merged commit ad16757 into dev Feb 21, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ Feature 기능 추가 무조건 스프린트내에 해야하는 것들 🎮 BE 백엔드

Projects

None yet

Development

Successfully merging this pull request may close these issues.

히스토리서버 과거 채팅 조회 api(정방향) 구현

3 participants