Skip to content

[FIX/#294] SSE API 응답 구조 수정 - #295

Merged
seungjunGong merged 8 commits into
developfrom
fix/#294-sse_api
Mar 30, 2026
Merged

[FIX/#294] SSE API 응답 구조 수정#295
seungjunGong merged 8 commits into
developfrom
fix/#294-sse_api

Conversation

@seungjunGong

@seungjunGong seungjunGong commented Mar 28, 2026

Copy link
Copy Markdown
Member

Related issue 🛠

Work Description ✏️

  • 기존 삭제했던 CANCELED 상태 복구 (*경기 결과 재반려시, SSE 이벤트로 받음)
  • 자동 로그인, 로그아웃, 탈퇴시 SSE 임시 연결로직 적용
  • 경기 결과 제출시 서버 에러메시지 다이얼로그 로직추가(NetworkErrorResponse 부분)
  • userId -> profileId 및 서버 응답 구조에 맞게 반영
  • 알림 관련 SSE 이벤트 및 DTO 제거

Screenshot 📸

  • N/A

Uncompleted Tasks 😅

  • 네트워크 연결 감지 추가(이후 pr 에서 작업 예정)
  • SSE 연결 로직 리팩(이후 pr 에서 작업 예정)

To Reviewers 📢

SSE 관련 DTO 를 수정했습니다.
경기 결과 제출시에 정책(24시간 lock, 10분 lock, host lock)등 여러 락이 걸리는 경우가 있어, 임시로 다이얼로그로 error message 를 보여주고자 NetworkErrorResponse 로 처리해두었습니다.

아직 SSE 연결 로직 관련 리팩이 완전히 완료된건 아니여서 1차 스프린트까진 해당 상태로 임시로 두고 추후에 위에 적힌 남은 작업 pr 올릴게요 !

Summary by CodeRabbit

릴리스 노트

  • 새로운 기능

    • 게임 결과 취소 상태 지원 추가
  • 버그 수정

    • 게임 제출 및 리뷰 작성 실패 시 더 정확한 오류 메시지 표시
  • 리팩토링

    • 내부 SSE 이벤트 처리 최적화
    • 로그인/로그아웃 시 세션 관리 개선

- GameResultStatusType에 CANCELED enum 추가
- MatchingViewModel 및 HomeViewModel에서 게임 취소 시 UI 상태 업데이트 로직 반영
- HomeViewModel 내 미사용 UserRepository import 제거
- GameResultStatusType에 CANCELED enum 추가
- MatchingViewModel 및 HomeViewModel에서 게임 취소 시 UI 상태 업데이트 로직 반영
- HomeViewModel 내 미사용 UserRepository import 제거
- NetworkErrorResponse DTO 및 Throwable 확장 함수 추가
- SubmitViewModel에서 에러 발생 시 throwable 메시지를 전달하도록 수정
- SubmitReviewScreen에서 실패 시 다이얼로그에 서버 에러 메시지 노출
- Requester의 userId를 profileId(requesterProfileId)로 변경
- MatchingReceivedDto의 sportId(Long)를 sportCode(String)로 변경
- 필드 변경에 따른 Mapper 및 ViewModel 로직 수정
- MatchingRequest, MatchingAccept, GameResultSubmitted, GameResultRejected, ReviewReceived 등 알림 관련 SSE 이벤트 타입 제거
- 관련 Dto(GameResultRejectedNotificationDto 등 5종) 및 Mapper 삭제
- `SseEventType` 및 `SseEvent` 모델에서 알림 관련 정의 제거
- `EventRepositoryImpl` 내 알림 이벤트 역직렬화 로직 제거
@coderabbitai

coderabbitai Bot commented Mar 28, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto incremental 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

Run ID: ce104b53-c14b-4cca-b9d6-2ac31f3bef0e

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

Walkthrough

SSE 응답 구조를 재정의하여 여러 알림 DTO 및 이벤트 타입을 제거하고, 요청자/스포츠 식별자 필드명을 변경하며, 게임 결과 상태에 CANCELED를 추가하고, 데이터 매핑 및 뷰모델을 업데이트했습니다. 에러 응답 처리 로직도 추가되었습니다.

Changes

Cohort / File(s) Summary
SSE 이벤트 및 DTO 제거
app/src/main/java/com/smashing/app/data/remote/dto/event/*NotificationDto.kt, app/src/main/java/com/smashing/app/data/model/event/SseEvent.kt, app/src/main/java/com/smashing/app/data/type/SseEventType.kt
매칭 요청, 수락, 게임 결과 제출/거부, 리뷰 수신 관련 5개 알림 DTO 파일과 해당 SseEvent 구현체, SseEventType 상수 제거
DTO 필드명 변경
app/src/main/java/com/smashing/app/data/remote/dto/event/common/RequesterDto.kt, app/src/main/java/com/smashing/app/data/remote/dto/event/MatchingReceivedDto.kt
RequesterDto의 userIdrequesterProfileId, MatchingReceivedDto의 sportIdsportCode 변경
도메인 모델 및 매퍼 업데이트
app/src/main/java/com/smashing/app/data/model/event/Requester.kt, app/src/main/java/com/smashing/app/data/mapper/event/EventMapper.kt, app/src/main/java/com/smashing/app/data/repository/impl/EventRepositoryImpl.kt
Requester 모델의 userIdprofileId 변경, EventMapper에서 제거된 DTO 매퍼 정리 및 sportCode 기반 매핑 추가, EventRepository에서 제거된 이벤트 타입 처리 삭제
게임 상태 타입 및 UI 업데이트
app/src/main/java/com/smashing/app/data/type/GameResultStatusType.kt, app/src/main/java/com/smashing/app/core/designsystem/style/ButtonStyle.kt
GameResultStatusType에 CANCELED 상수 추가, ButtonStyle의 getMatchButtonColor(), getMatchButtonTitle() 메서드에 CANCELED 처리 추가
에러 응답 처리 추가
app/src/main/java/com/smashing/app/data/remote/dto/BaseResponse.kt, app/src/main/java/com/smashing/app/data/repository/impl/GameRepositoryImpl.kt
NetworkErrorResponse 데이터 클래스 및 확장 함수 추가, GameRepositoryImpl에 Json 주입 및 에러 메시지 변환 로직 추가
뷰모델 SSE 핸들링 업데이트
app/src/main/java/com/smashing/app/presentation/matching/MatchingViewModel.kt, app/src/main/java/com/smashing/app/presentation/home/HomeViewModel.kt
MatchingViewModel에서 requester.profileId 사용 및 CANCELED 상태 처리 추가, HomeViewModel에서 CANCELED 상태에 대한 matchedUser 초기화 로직 추가
뷰모델 로그아웃 SSE 처리
app/src/main/java/com/smashing/app/presentation/mypage/MyPageViewModel.kt, app/src/main/java/com/smashing/app/presentation/withdraw/WithdrawViewModel.kt, app/src/main/java/com/smashing/app/presentation/splash/SplashViewModel.kt
로그아웃/회원탈퇴/로그인 시점에 SseManager 주입 및 SSE 상태 관리 메서드 호출 추가
서브밋 화면 에러 메시지 처리
app/src/main/java/com/smashing/app/presentation/write/submit/SubmitReviewScreen.kt, app/src/main/java/com/smashing/app/presentation/write/submit/SubmitViewModel.kt
SubmitViewModel에서 실패 시 예외 메시지 캡처하여 Failure 상태에 저장, SubmitReviewScreen에서 동적 실패 메시지 표시

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

🔨 FIX

Suggested reviewers

  • ShinHyeongcheol
  • vahkjsdf
  • oilbeaneda
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 SSE API 응답 구조 수정이라는 주요 변경사항을 명확하게 요약하고 있으며, 실제 변경내용(DTO 구조 변경, SSE 이벤트 제거, profileId 변경 등)과 일치합니다.
Description check ✅ Passed PR 설명이 템플릿을 따르고 있으며, Related issue, Work Description, 완료되지 않은 작업, 검수자 참고사항 등이 충분히 작성되어 있습니다.
Linked Issues check ✅ Passed PR의 모든 주요 변경사항들(SSE 응답 구조 개선, DTO 구조 변경, userId→profileId 변경, 알림 이벤트 제거 등)이 #294의 'SSE 응답 구조 수정'이라는 목표와 부합합니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 SSE 응답 구조 개선이라는 스코프 내에 있으며, CANCELED 상태 추가, 에러 메시지 다이얼로그, SSE 연결 로직 등이 모두 관련 이슈와 부합합니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/#294-sse_api

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 and usage tips.

@seungjunGong seungjunGong changed the title [Fix/#294] SSE API 응답 구조 수정 [FIX/#294] SSE API 응답 구조 수정 Mar 28, 2026
@seungjunGong seungjunGong added the 🔨 FIX 버그 수정 label Mar 28, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
app/src/main/java/com/smashing/app/presentation/splash/SplashViewModel.kt (1)

45-46: SSE 연결 완료 보장 없이 홈 이동이 발생합니다.

현재는 onUserLoggedIn()이 fire-and-forget으로 실행되어, 홈 진입 직후 초기 SSE 이벤트를 놓칠 여지가 있습니다. 임시 로직 정리 시점에 연결 준비 상태를 확인한 뒤 네비게이션을 발생시키는 구조로 합치는 것을 권장합니다.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/main/java/com/smashing/app/presentation/splash/SplashViewModel.kt`
around lines 45 - 46, The current flow fires sseManager.onUserLoggedIn() and
immediately emits _sideEffect.emit(NavigateToHome), risking missed initial SSE
events; change the logic so navigation happens only after SSE reports a
ready/connected state. Concretely, update or overload
sseManager.onUserLoggedIn() to provide a readiness signal (e.g., a suspend
return value, callback, or expose a ConnectionState/Flow) and in SplashViewModel
wait for that ready signal before calling _sideEffect.emit(NavigateToHome);
alternatively observe sseManager.connectionState (or add one) and emit
NavigateToHome only when it reports CONNECTED/READY. Ensure the modification
references sseManager.onUserLoggedIn() and _sideEffect.emit(NavigateToHome).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@app/src/main/java/com/smashing/app/presentation/write/submit/SubmitViewModel.kt`:
- Around line 193-198: The failure branch in SubmitViewModel currently only
falls back on a default message when throwable.message is null, so empty or
whitespace messages slip through; update the onFailure handling (the
_uiState.update call that sets SubmitContract.SubmitUiState.Failure) to treat
empty/blank strings as missing by using a blank-aware check (e.g., use
throwable.message.takeIf { !it.isNullOrBlank() } ?: "매칭 결과를 확인해주세요." or
equivalent) so the default message is applied when message is null, empty, or
only whitespace.

---

Nitpick comments:
In `@app/src/main/java/com/smashing/app/presentation/splash/SplashViewModel.kt`:
- Around line 45-46: The current flow fires sseManager.onUserLoggedIn() and
immediately emits _sideEffect.emit(NavigateToHome), risking missed initial SSE
events; change the logic so navigation happens only after SSE reports a
ready/connected state. Concretely, update or overload
sseManager.onUserLoggedIn() to provide a readiness signal (e.g., a suspend
return value, callback, or expose a ConnectionState/Flow) and in SplashViewModel
wait for that ready signal before calling _sideEffect.emit(NavigateToHome);
alternatively observe sseManager.connectionState (or add one) and emit
NavigateToHome only when it reports CONNECTED/READY. Ensure the modification
references sseManager.onUserLoggedIn() and _sideEffect.emit(NavigateToHome).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2145cae5-599d-406a-8ee7-bd408cea76ea

📥 Commits

Reviewing files that changed from the base of the PR and between 4ddfe4a and 8215ffc.

📒 Files selected for processing (23)
  • app/src/main/java/com/smashing/app/core/designsystem/style/ButtonStyle.kt
  • app/src/main/java/com/smashing/app/data/mapper/event/EventMapper.kt
  • app/src/main/java/com/smashing/app/data/model/event/Requester.kt
  • app/src/main/java/com/smashing/app/data/model/event/SseEvent.kt
  • app/src/main/java/com/smashing/app/data/remote/dto/BaseResponse.kt
  • app/src/main/java/com/smashing/app/data/remote/dto/event/GameResultRejectedNotificationDto.kt
  • app/src/main/java/com/smashing/app/data/remote/dto/event/GameResultSubmittedNotificationDto.kt
  • app/src/main/java/com/smashing/app/data/remote/dto/event/MatchingAcceptNotificationDto.kt
  • app/src/main/java/com/smashing/app/data/remote/dto/event/MatchingReceivedDto.kt
  • app/src/main/java/com/smashing/app/data/remote/dto/event/MatchingRequestNotificationDto.kt
  • app/src/main/java/com/smashing/app/data/remote/dto/event/ReviewReceivedNotificationDto.kt
  • app/src/main/java/com/smashing/app/data/remote/dto/event/common/RequesterDto.kt
  • app/src/main/java/com/smashing/app/data/repository/impl/EventRepositoryImpl.kt
  • app/src/main/java/com/smashing/app/data/repository/impl/GameRepositoryImpl.kt
  • app/src/main/java/com/smashing/app/data/type/GameResultStatusType.kt
  • app/src/main/java/com/smashing/app/data/type/SseEventType.kt
  • app/src/main/java/com/smashing/app/presentation/home/HomeViewModel.kt
  • app/src/main/java/com/smashing/app/presentation/matching/MatchingViewModel.kt
  • app/src/main/java/com/smashing/app/presentation/mypage/MyPageViewModel.kt
  • app/src/main/java/com/smashing/app/presentation/splash/SplashViewModel.kt
  • app/src/main/java/com/smashing/app/presentation/withdraw/WithdrawViewModel.kt
  • app/src/main/java/com/smashing/app/presentation/write/submit/SubmitReviewScreen.kt
  • app/src/main/java/com/smashing/app/presentation/write/submit/SubmitViewModel.kt
💤 Files with no reviewable changes (7)
  • app/src/main/java/com/smashing/app/data/remote/dto/event/MatchingRequestNotificationDto.kt
  • app/src/main/java/com/smashing/app/data/remote/dto/event/MatchingAcceptNotificationDto.kt
  • app/src/main/java/com/smashing/app/data/remote/dto/event/GameResultRejectedNotificationDto.kt
  • app/src/main/java/com/smashing/app/data/repository/impl/EventRepositoryImpl.kt
  • app/src/main/java/com/smashing/app/data/remote/dto/event/GameResultSubmittedNotificationDto.kt
  • app/src/main/java/com/smashing/app/data/remote/dto/event/ReviewReceivedNotificationDto.kt
  • app/src/main/java/com/smashing/app/data/model/event/SseEvent.kt

Comment on lines +193 to +198
}.onFailure { throwable ->
_uiState.update {
it.copy(
submitUiState = SubmitContract.SubmitUiState.Failure("경기 결과 제출 실패"),
submitUiState = SubmitContract.SubmitUiState.Failure(
throwable.message ?: "매칭 결과를 확인해주세요."
),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

빈/공백 에러 메시지 처리 누락으로 안내 문구가 비어질 수 있습니다.

Line 197은 null만 fallback 처리합니다. "" 또는 " "인 경우 기본 문구가 적용되지 않습니다.

수정 제안
         }.onFailure { throwable ->
             _uiState.update {
                 it.copy(
                     submitUiState = SubmitContract.SubmitUiState.Failure(
-                        throwable.message ?: "매칭 결과를 확인해주세요."
+                        throwable.message?.takeUnless { message -> message.isBlank() }
+                            ?: "매칭 결과를 확인해주세요."
                     ),
                     isResubmitDialogVisible = false,
                     isAlertDialogOpen = false,
                     isConfirmDialogOpen = true,
                 )
             }
         }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
}.onFailure { throwable ->
_uiState.update {
it.copy(
submitUiState = SubmitContract.SubmitUiState.Failure("경기 결과 제출 실패"),
submitUiState = SubmitContract.SubmitUiState.Failure(
throwable.message ?: "매칭 결과를 확인해주세요."
),
}.onFailure { throwable ->
_uiState.update {
it.copy(
submitUiState = SubmitContract.SubmitUiState.Failure(
throwable.message?.takeUnless { message -> message.isBlank() }
?: "매칭 결과를 확인해주세요."
),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@app/src/main/java/com/smashing/app/presentation/write/submit/SubmitViewModel.kt`
around lines 193 - 198, The failure branch in SubmitViewModel currently only
falls back on a default message when throwable.message is null, so empty or
whitespace messages slip through; update the onFailure handling (the
_uiState.update call that sets SubmitContract.SubmitUiState.Failure) to treat
empty/blank strings as missing by using a blank-aware check (e.g., use
throwable.message.takeIf { !it.isNullOrBlank() } ?: "매칭 결과를 확인해주세요." or
equivalent) so the default message is applied when message is null, empty, or
only whitespace.

@oilbeaneda oilbeaneda 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.

수고하셨습니다라락

@ShinHyeongcheol ShinHyeongcheol 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.

응답 구조 수정을 봤을 때는 문제 없는 것 같아요!!
BaseResponse에 NetworkErrorResponse처럼 만들까 말까 고민했었는데, 기존 에러 관련 Response 활용하는 부분 수정해봐도 좋겠네요

@vahkjsdf vahkjsdf 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.

수고하셨습니당

@seungjunGong
seungjunGong merged commit a124abc into develop Mar 30, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 FIX 버그 수정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FIX] SSE 응답 구조 수정

4 participants