From 87c47f814331a54ccbd463de1856cabb771ae84e Mon Sep 17 00:00:00 2001 From: Klaus Date: Fri, 3 Apr 2026 11:38:00 +0900 Subject: [PATCH] =?UTF-8?q?fix(chat):=20=EC=99=B8=EB=B6=80=20=EC=B1=84?= =?UTF-8?q?=ED=8C=85=20API=20=EC=9A=94=EC=B2=AD=EC=97=90=20username?= =?UTF-8?q?=EC=9D=84=20=EC=A0=84=EB=8B=AC=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/20260403_메시지전송username추가.md | 10 ++++++++++ .../sodalive/chat/room/service/ChatRoomService.kt | 7 +++++-- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 docs/20260403_메시지전송username추가.md diff --git a/docs/20260403_메시지전송username추가.md b/docs/20260403_메시지전송username추가.md new file mode 100644 index 00000000..672c8690 --- /dev/null +++ b/docs/20260403_메시지전송username추가.md @@ -0,0 +1,10 @@ +- [x] sendMessage의 외부 채팅 API 호출 경로와 요청 payload 구성을 확인한다. +- [x] 외부 `/api/chat` 요청 body에 `member.nickname`을 `username` 파라미터로 전달하도록 수정한다. +- [x] 변경 파일 기준으로 검증을 수행하고 결과를 기록한다. + +## 검증 기록 + +### 1차 구현 +- 무엇을: `ChatRoomService.sendMessage`가 외부 `/api/chat` 호출 시 `member.nickname`을 `username` 파라미터로 함께 전달하도록 수정했다. +- 왜: 외부 채팅 API가 사용자 닉네임을 함께 받아야 하는 요구사항을 기존 메시지 전송 흐름 안에서 최소 범위로 반영해야 했기 때문이다. +- 어떻게: 내부 탐색으로 `/api/chat` payload 생성 위치가 `ChatRoomService.callExternalApiForChatSend`임을 확인한 뒤 `./gradlew compileKotlin`과 `./gradlew test`를 실행했고 둘 다 `BUILD SUCCESSFUL`이었다. 추가로 `./gradlew test --tests '*ChatRoom*'`를 시도했지만 해당 패턴의 테스트 클래스는 없어 필터 검증은 불가했다. diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/chat/room/service/ChatRoomService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/chat/room/service/ChatRoomService.kt index 4219c26c..747937d0 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/chat/room/service/ChatRoomService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/chat/room/service/ChatRoomService.kt @@ -672,7 +672,7 @@ class ChatRoomService( ) // 6) 외부 API 호출 (최대 3회 재시도) - val characterReply = callExternalApiForChatSendWithRetry(userId, characterUUID, message, sessionId) + val characterReply = callExternalApiForChatSendWithRetry(userId, member.nickname, characterUUID, message, sessionId) // 6) 내 메시지 저장 val myMsgEntity = ChatMessage( @@ -827,6 +827,7 @@ class ChatRoomService( private fun callExternalApiForChatSendWithRetry( userId: String, + username: String, characterUUID: String, message: String, sessionId: String @@ -836,7 +837,7 @@ class ChatRoomService( while (attempt < maxAttempts) { attempt++ try { - return callExternalApiForChatSend(userId, characterUUID, message, sessionId) + return callExternalApiForChatSend(userId, username, characterUUID, message, sessionId) } catch (e: Exception) { log.warn("[chat] 외부 채팅 전송 실패 attempt={}, error={}", attempt, e.message) } @@ -847,6 +848,7 @@ class ChatRoomService( private fun callExternalApiForChatSend( userId: String, + username: String, characterUUID: String, message: String, sessionId: String @@ -863,6 +865,7 @@ class ChatRoomService( val requestBody = mapOf( "userId" to userId, + "username" to username, "characterId" to characterUUID, "message" to message, "sessionId" to sessionId