Skip to content

[DP-484] 커뮤니티 본인 답변 채택 버튼 노출 및 채택 허용 버그 수정#172

Merged
nYeonG4001 merged 2 commits into
developV2from
fix/DP-484-answer-can-adopt-field
May 18, 2026
Merged

[DP-484] 커뮤니티 본인 답변 채택 버튼 노출 및 채택 허용 버그 수정#172
nYeonG4001 merged 2 commits into
developV2from
fix/DP-484-answer-can-adopt-field

Conversation

@nYeonG4001
Copy link
Copy Markdown
Collaborator

Summary

  • AnswerWithCommentsResponsecanAdopt 필드 추가 — 서버가 채택 가능 여부를 계산해서 응답
  • GET /posts/{postId}/answers@AuthenticationPrincipal userId 추가 — 현재 유저 기준으로 canAdopt 판단
  • adoptAnswer()에 본인 답변 채택 서버 측 검증 추가 — API 직접 호출 시에도 차단 (COMMUNITY_015)

Root Cause

프론트에서 canAdopt 조건을 직접 계산하다가 "본인 답변 여부" 체크가 누락되어, 게시글 작성자가 본인 답변에도 채택 버튼이 노출됨. 서버의 adoptAnswer()도 본인 답변 채택을 막지 않았음.

canAdopt 계산 조건 (서버)

조건 설명
currentUser == postAuthor 게시글 작성자만 채택 가능
!anyAdopted 이미 채택된 답변 없음
!answer.isAdopted 이 답변이 채택 상태 아님
answerAuthor != currentUser 본인 답변 채택 불가

Test plan

  • AnswerServiceTestcanAdopt 경계 조건 4가지 + 본인 답변 채택 예외 포함 전체 통과
  • AnswerControllerTestcanAdopt 응답 필드 검증 + 403 반환 확인
  • ./gradlew build 전체 빌드 통과

@sonarqubecloud
Copy link
Copy Markdown

@nYeonG4001 nYeonG4001 merged commit 05259bd into developV2 May 18, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant