fix(chat): 외부 채팅 API 요청에 username을 전달한다

This commit is contained in:
2026-04-03 11:38:00 +09:00
parent a5ce4b6e0a
commit 87c47f8143
2 changed files with 15 additions and 2 deletions

View File

@@ -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*'`를 시도했지만 해당 패턴의 테스트 클래스는 없어 필터 검증은 불가했다.

View File

@@ -672,7 +672,7 @@ class ChatRoomService(
) )
// 6) 외부 API 호출 (최대 3회 재시도) // 6) 외부 API 호출 (최대 3회 재시도)
val characterReply = callExternalApiForChatSendWithRetry(userId, characterUUID, message, sessionId) val characterReply = callExternalApiForChatSendWithRetry(userId, member.nickname, characterUUID, message, sessionId)
// 6) 내 메시지 저장 // 6) 내 메시지 저장
val myMsgEntity = ChatMessage( val myMsgEntity = ChatMessage(
@@ -827,6 +827,7 @@ class ChatRoomService(
private fun callExternalApiForChatSendWithRetry( private fun callExternalApiForChatSendWithRetry(
userId: String, userId: String,
username: String,
characterUUID: String, characterUUID: String,
message: String, message: String,
sessionId: String sessionId: String
@@ -836,7 +837,7 @@ class ChatRoomService(
while (attempt < maxAttempts) { while (attempt < maxAttempts) {
attempt++ attempt++
try { try {
return callExternalApiForChatSend(userId, characterUUID, message, sessionId) return callExternalApiForChatSend(userId, username, characterUUID, message, sessionId)
} catch (e: Exception) { } catch (e: Exception) {
log.warn("[chat] 외부 채팅 전송 실패 attempt={}, error={}", attempt, e.message) log.warn("[chat] 외부 채팅 전송 실패 attempt={}, error={}", attempt, e.message)
} }
@@ -847,6 +848,7 @@ class ChatRoomService(
private fun callExternalApiForChatSend( private fun callExternalApiForChatSend(
userId: String, userId: String,
username: String,
characterUUID: String, characterUUID: String,
message: String, message: String,
sessionId: String sessionId: String
@@ -863,6 +865,7 @@ class ChatRoomService(
val requestBody = mapOf( val requestBody = mapOf(
"userId" to userId, "userId" to userId,
"username" to username,
"characterId" to characterUUID, "characterId" to characterUUID,
"message" to message, "message" to message,
"sessionId" to sessionId "sessionId" to sessionId