Skip to content

FEAT: 채팅 텍스트 메시지 전송, 읽음, SSE, 방 음소거 및 S3 인프라 구성#59

Merged
seokMini-2 merged 12 commits into
developfrom
feat/#50
Jul 24, 2026
Merged

FEAT: 채팅 텍스트 메시지 전송, 읽음, SSE, 방 음소거 및 S3 인프라 구성#59
seokMini-2 merged 12 commits into
developfrom
feat/#50

Conversation

@seokMini-2

Copy link
Copy Markdown
Collaborator

Summary

  • 채팅 도메인의 메시지 송수신 파이프라인과 S3 업로드 인프라를 구현했습니다.

Related Issue

Describe your code

  • 작업 내용 (What I Did) :
  • 메시지 전송(텍스트) POST /chat-rooms/{id}/messages
    • 방 소유 검증 후 USER/TEXT 메시지 저장, 저장된 메시지 반환(201)
  • 읽음 처리 PATCH /chat-rooms/{id}/read
    • 안 읽은 수신 메시지(USER 제외)를 cutoff 기준 일괄 읽음 처리
  • SSE 파이프라인 GET /chat-rooms/subscribe
    • 유저당 전역 1연결, heartbeat 15초, timeout 30분
  • AI 답장 뼈대
    • 유저 전송 커밋 후 비동기(@async) 이벤트 → AI 서버 호출 → SSE push
    • AI 실패해도 유저 전송(201)에는 영향 없음
  • 채팅방 음소거 PATCH /chat-rooms/{id}/mute
    • 음소거 방은 이후 FCM 발송에서 제외 예정
  • S3 업로드 인프라
    • AWS SDK v2, S3Config, S3Uploader(업로드/삭제, global/infra)
    • 실제 버킷 왕복 검증 완료(업로드/조회/삭제)
  • 스크린샷/결과 (Optional) :
image
  • 논의사항/질문 (To Reviewers) :
  • AI 응답 연동 최종 검증 대기: AI 서버 /chat 요청 DTO 계약 불일치(요청 필드값)가 있었습니다. 아래 내용을 다음 pr에서 확인하려고 합니다.
    • ai모델의 채팅 쪽에서도 요청 필드값 점검
    • 채팅 메시지 전송 -> AI 답장(SSE) 정상 수신 여부
    • 이미지 메시지 전송-> AI 답장(SSE) 정상 수신 여부

Checklist

  • 리뷰어 등록

@seokMini-2 seokMini-2 self-assigned this Jul 23, 2026
@seokMini-2 seokMini-2 added the FEAT 기능 구현 label Jul 23, 2026
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2f736635-1def-4293-afb1-c8dfce0c68c0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/#50

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.

@github-actions

Copy link
Copy Markdown

🛡️ 문제점

  • S3Uploader.java: file.getInputStream()이 try-with-resources 블록 없이 열려 파일 업로드 시 시스템 리소스 핸들 누수가 발생합니다.

💡 개선 사항

  • 서비스 계층에서 수동으로 null 검사를 하는 대신 컨트롤러 DTO/파라미터에 @NotBlank를 사용하여 메시지 내용을 검증하십시오.
  • S3Uploader에 반복되는 S3 기본 URL 문자열 서식을 재사용 가능한 단일 상수 또는 헬퍼 메서드로 통합하십시오.
  • AiReplyEventListener에서 읽기 전용 기록 가져오기를 @Transactional(readOnly = true)로 명시적으로 표시하십시오.

@github-actions

Copy link
Copy Markdown

💡 개선 사항

  • S3Uploader.extractKey에서 문자열 교체 대신 java.net.URI 경로 파싱을 사용하여 키 파싱 오류를 방지하세요.
  • S3Uploader.upload 내부에서 file.getInputStream()try-with-resources 블록으로 감싸 스트림이 확실히 닫히도록 보장하세요.
  • AiReplyEventListener.onUserMessageSent@Transactional(readOnly = true)를 추가하여 활성 영속성 컨텍스트 내에서 엔티티 조회가 안전하게 작동하도록 하세요.

@oofrog oofrog left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

수고하셨습니다. 아래 코멘트 확인해주세요

Comment thread src/main/java/com/example/umcCall/domain/chat/service/AiReplyGenerator.java Outdated
Comment thread src/main/java/com/example/umcCall/domain/chat/service/ChatSseService.java Outdated

@hyeonky0w0 hyeonky0w0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

수고하셨습니다!

return;
}

ChatMessage aiMessage = chatMessageService.saveAiMessage(event.chatRoomId(), reply);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI 메시지를 DB에 저장한 뒤 SSE로 한 번만 전송하고 있어서, 연결이 잠시 끊긴 경우 클라이언트가 해당 답장을 실시간으로 놓칠 수 있을 것 같습니다. 재연결 시 메시지 목록을 다시 조회하도록 프론트와 계약되어 있는지 확인하거나, 마지막 수신 메시지 이후를 다시 가져오는 복구 방식이 있으면 좋을 것 같습니다.

@github-actions

Copy link
Copy Markdown

개선 사항

  • ChatMessageController.sendMessage에서 @RequestParam 대신 전용 요청 본문 DTO(@RequestBody)를 사용하여 향후 페이로드 확장성을 확보하세요.
  • S3Uploader의 일반적인 RuntimeException을 사용자 정의 전역/도메인 예외로 교체하여 일관된 오류 응답을 제공하세요.
  • S3Uploader에서 반복되는 S3 URL 접두사 형식 지정 로직을 DRY 원칙을 준수하는 private 헬퍼 메서드 또는 상수로 추출하세요.

@github-actions

Copy link
Copy Markdown

💡 개선 사항

  • AiReplyEventListener에서 조건부 문자열 변환을 수행하는 대신, 역할 매핑 로직을 SenderType 내부에 캡슐화하십시오.
  • ChatMessageService 내의 중복된 ChatMessage 생성 및 lastMessageAt 업데이트 로직을 private 헬퍼 메서드로 추출하십시오.
  • S3Uploader에서 반복적인 문자열 연결을 방지하기 위해 S3 URL 접두사 구성을 위한 단일 상수 또는 헬퍼를 정의하십시오.

@github-actions

Copy link
Copy Markdown

🛡️ 문제점

  • AiReplyDebounceransweredWatermark가 채팅방 키를 무기한으로 보유하여 채팅방이 증가함에 따라 무한 메모리 누수를 발생시킵니다.

💡 개선 사항

  • S3Uploader에서 일반적인 RuntimeException을 커스텀 도메인 예외로 대체합니다.
  • AiReplyDebouncertimer 필드 이름을 해당 타입과 목적을 더 잘 반영하도록 taskScheduler로 변경합니다.
  • DRY 원칙을 따르기 위해 S3Uploader에서 반복되는 S3 URL 도메인 접두사 문자열을 상수로 추출합니다.

@seokMini-2
seokMini-2 merged commit ad93eee into develop Jul 24, 2026
2 checks passed
@seokMini-2
seokMini-2 deleted the feat/#50 branch July 24, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FEAT 기능 구현

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨ [FEAT] 채팅 메시지 전송 구현

3 participants