-
Notifications
You must be signed in to change notification settings - Fork 1
[hotfix] 사용자 팔로워 조회시 나인지 여부 반환 플래그 반환 #269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -263,7 +263,7 @@ void getFeedsByBook_cursor_paging_success() throws Exception { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @Test | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @DisplayName("비공개 피드 제외 및 자기 자신 피드 제외 검증") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @DisplayName("비공개 피드 제외 검증") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| void getFeedsByBook_visibility_and_self_filter() throws Exception { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // given | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AliasJpaEntity alias = aliasJpaRepository.save(TestEntityFactory.createLiteratureAlias()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -304,7 +304,7 @@ void getFeedsByBook_visibility_and_self_filter() throws Exception { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| JsonNode feeds = root.path("data").path("feeds"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 자기 자신 글 제외 비공개 제외로 인해 only othersPublic 만 남아야 함 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assertThat(feeds.size()).isEqualTo(1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assertThat(feeds.size()).isEqualTo(2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assertThat(feeds.get(0).path("creatorId").asLong()).isEqualTo(other.getUserId()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assertThat(feeds.get(0).path("isWriter").asBoolean()).isFalse(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
306
to
310
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 주석/검증 불일치 및 순서 의존으로 인한 테스트 취약성
아래처럼 순서 비의존적이고 새로운 요구사항에 맞는 검증으로 교체해 주세요. 다음 diff를 적용하세요: - // 자기 자신 글 제외 비공개 제외로 인해 only othersPublic 만 남아야 함
- assertThat(feeds.size()).isEqualTo(2);
- assertThat(feeds.get(0).path("creatorId").asLong()).isEqualTo(other.getUserId());
- assertThat(feeds.get(0).path("isWriter").asBoolean()).isFalse();
+ // 비공개 제외 + 자기 자신 글 포함 검증: 공개 글 2개만 반환되어야 함
+ assertThat(feeds.size()).isEqualTo(2);
+
+ boolean hasMyPublic = false;
+ boolean hasOthersPublic = false;
+ for (JsonNode f : feeds) {
+ long creatorId = f.path("creatorId").asLong();
+ boolean isWriter = f.path("isWriter").asBoolean();
+ if (creatorId == requester.getUserId()) {
+ assertThat(isWriter).isTrue();
+ hasMyPublic = true;
+ }
+ if (creatorId == other.getUserId()) {
+ assertThat(isWriter).isFalse();
+ hasOthersPublic = true;
+ }
+ }
+ assertThat(hasMyPublic).isTrue();
+ assertThat(hasOthersPublic).isTrue();📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
isMyself 컨텍스트에 잘못된 userId가 전달되어 항상 false가 됩니다
현재
.map(dto -> followQueryMapper.toFollowerDto(dto, userId))에서 전달되는userId는 "조회 대상 사용자"의 ID입니다. 그러나 요구사항의 isMyself는 "로그인 사용자" 기준이어야 합니다. 대상 사용자의 팔로워 목록에는 대상 사용자 본인이 포함될 수 없기 때문에, 현 구현은 isMyself가 사실상 항상 false가 되는 버그를 유발합니다.즉, Mapper에는 로그인 사용자 ID를 전달해야 합니다.
권장 수정 방향:
해당 라인에 대한 변경 예시는 다음과 같습니다(참고: 아래 코드는 새로운 매개변수 도입을 전제로 합니다).
시그니처 변경(파일 외부 변경)은 아래처럼 반영되어야 합니다:
다음 스크립트로 호출부와 시그니처를 점검해 주세요. 기대: 컨트롤러(혹은 호출자)가 로그인 사용자 ID를 별도 인자로 전달하지 않고 있을 가능성이 높습니다.
원하시면 컨트롤러/유스케이스/테스트까지 포함한 전체 변경 패치를 준비하겠습니다.
🏁 Script executed:
Length of output: 16191
로그인 사용자 ID를 컨트롤러→서비스→매퍼로 전달해 isMyself를 올바르게 계산하세요
현재
getUserFollowers(Long userId, String cursor, int size)메서드에 대상 사용자 ID만 전달되고 있어,followQueryMapper.toFollowerDto(dto, userId)호출 시 isMyself가 항상 false로 처리됩니다.isMyself는 “로그인한 사용자” 기준이어야 합니다.
수정이 필요한 위치:
(src/main/java/.../service/following/UserGetFollowService.java: 라인 29–40)
(src/main/java/.../adapter/in/web/UserQueryController.java: 라인 81)
followQueryMapper.toFollowerDto(dto, userId)→followQueryMapper.toFollowerDto(dto, loginUserId)예시 diff:
테스트 및 매퍼 구현도 함께 업데이트해야 합니다.
📝 Committable suggestion
🤖 Prompt for AI Agents