Skip to content

Comments

[REFACTOR] 차단 여부 조회 api 추가#143

Merged
e2guana merged 3 commits intodevfrom
feat/142-block-refactor
Dec 13, 2025
Merged

[REFACTOR] 차단 여부 조회 api 추가#143
e2guana merged 3 commits intodevfrom
feat/142-block-refactor

Conversation

@e2guana
Copy link
Contributor

@e2guana e2guana commented Dec 13, 2025

🎋 이슈 및 작업중인 브랜치

#142

🔑 주요 내용

-refactor로 기존 채팅 목록 조회에 추가하는 방식으로 하려했으나 새로 api를 추가하는 방식으로 하여 사실상 feat
-차단 여부 목록 조회 방식 (이전 pr 코드래빗 피드백 반영)
image
상대방 차단일때 true
image
상대방 차단 해제일때 false 반환

Check List

  • Reviewers 등록을 하였나요?
  • Assignees 등록을 하였나요?
  • 라벨(Label) 등록을 하였나요?
  • PR 머지하기 전 반드시 CI가 정상적으로 작동하는지 확인해주세요!

Summary by CodeRabbit

  • New Features

    • Added endpoint to query block status between chat participants.
    • Chat summaries now show whether you have blocked the partner.
  • Improvements

    • Standardized block/unblock endpoint paths.
    • Improved validation and semantics for block/unblock actions, including clearer status responses.

✏️ Tip: You can customize this high-level summary in your review settings.

@e2guana e2guana self-assigned this Dec 13, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 13, 2025

Walkthrough

Adds block-status handling: moves block/unblock endpoints to /chats/{chatId}/block and /chats/{chatId}/unblock, adds GET /chats/{chatId}/block returning BlockStatusResponse, introduces iBlockedPartner on chat summaries, and updates service logic to compute and validate block relationships.

Changes

Cohort / File(s) Summary
Controller: block endpoints & query
src/main/java/com/salemale/domain/chat/controller/ChatController.java
Moved block/unblock mappings to /chats/{chatId}/block and /chats/{chatId}/unblock; added GET /chats/{chatId}/block -> getBlockStatus(...) returning ApiResponse<BlockStatusResponse).
New DTO: Block status
src/main/java/com/salemale/domain/chat/dto/BlockStatusResponse.java
New DTO with boolean iBlockedPartner and boolean partnerBlockedMe.
Chat DTO updates
src/main/java/com/salemale/domain/chat/dto/ChatDtos.java
Added iBlockedPartner field to ChatSummaryResponse (and related CreateChatRequest minor formatting).
Service: block logic & summaries
src/main/java/com/salemale/domain/chat/service/ChatService.java
Added getBlockStatus(me, chatId); preloads blocked user IDs for getChatSummaries and sets iBlockedPartner; enforces participant validation and adjusts blockPartner/unblockPartner semantics.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant ChatController
    participant ChatService
    participant ChatRepository
    participant BlockListRepository

    Client->>ChatController: GET /chats/{chatId}/block (user-id header)
    ChatController->>ChatService: getBlockStatus(me, chatId)
    ChatService->>ChatRepository: validate participant & resolve partnerId
    ChatRepository-->>ChatService: partnerId
    ChatService->>BlockListRepository: query isBlocked(me, partnerId)
    BlockListRepository-->>ChatService: iBlockedPartner
    ChatService->>BlockListRepository: query isBlocked(partnerId, me)
    BlockListRepository-->>ChatService: partnerBlockedMe
    ChatService-->>ChatController: BlockStatusResponse(iBlockedPartner, partnerBlockedMe)
    ChatController-->>Client: 200 ApiResponse<BlockStatusResponse>
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay attention to: participant validation in ChatService (edge cases), correctness of blocked-user preloading and Set lookup, and serialization/compatibility of added DTO fields.

Possibly related PRs

Suggested reviewers

  • nomorefifa
  • beans3142

Poem

🐰 hoppity-hop, I check who barred the gate,
Two booleans tell the tale of friend or spate,
Endpoints set, the statuses align,
I nibble insight from each chat line,
Carrot cheers for clear state 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title partially describes the changeset by mentioning the addition of a block status query API, but uses a non-English title and the [REFACTOR] prefix is misleading since the PR primarily adds new functionality rather than refactoring existing code. Consider revising the title to be in English and use [FEAT] instead of [REFACTOR] to accurately reflect that this PR introduces new API functionality rather than refactoring existing code.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/142-block-refactor

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.

@e2guana e2guana added ✨FEAT 기능 구현 관련 🔨RAFACTOR 리팩토링 관련 labels Dec 13, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/main/java/com/salemale/domain/chat/dto/BlockStatusResponse.java (1)

6-12: Consider using @Getter and @Builder for consistency.

The @Data annotation generates setters that are unnecessary for a response DTO. For consistency with other response DTOs in ChatDtos.java (e.g., ChatSummaryResponse, ChatResponse) and to ensure immutability, consider using @Getter with @Builder instead.

Apply this diff:

-@Data
+@Getter
+@Builder
 @AllArgsConstructor
+@NoArgsConstructor
 public class BlockStatusResponse {
-
     private boolean iBlockedPartner;   // 내가 상대를 차단했는지
     private boolean partnerBlockedMe;  // 상대가 나를 차단했는지
 }
src/main/java/com/salemale/domain/chat/service/ChatService.java (1)

61-63: Use imported types instead of fully qualified names.

Lines 63 uses fully qualified names java.util.Set and java.util.HashSet, but these types are already imported at lines 29 and 31. Use the short names for consistency.

Apply this diff:

         // 내가 차단한 사용자 id 목록을 한 번에 조회
         List<Long> blockedUserIds = blockListRepository.findBlockedUserIds(me);
-        java.util.Set<Long> blockedSet = new java.util.HashSet<>(blockedUserIds);
+        Set<Long> blockedSet = new HashSet<>(blockedUserIds);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8343f4e and 2f573f8.

📒 Files selected for processing (4)
  • src/main/java/com/salemale/domain/chat/controller/ChatController.java (4 hunks)
  • src/main/java/com/salemale/domain/chat/dto/BlockStatusResponse.java (1 hunks)
  • src/main/java/com/salemale/domain/chat/dto/ChatDtos.java (2 hunks)
  • src/main/java/com/salemale/domain/chat/service/ChatService.java (7 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (5)
src/main/java/com/salemale/domain/chat/dto/ChatDtos.java (1)

57-60: LGTM!

The iBlockedPartner field is correctly placed in ChatSummaryResponse and aligns with the block status feature implementation in the service layer.

src/main/java/com/salemale/domain/chat/controller/ChatController.java (1)

114-114: LGTM!

The route mappings follow RESTful conventions:

  • POST /chats/{chatId}/block creates a block
  • POST /chats/{chatId}/unblock removes a block
  • GET /chats/{chatId}/block queries block status

Spring MVC correctly distinguishes these endpoints by HTTP method, so there is no ambiguity.

Also applies to: 128-128, 137-145

src/main/java/com/salemale/domain/chat/service/ChatService.java (3)

114-115: LGTM!

The implementation efficiently checks block status using a preloaded Set for O(1) lookup, avoiding N+1 queries when building chat summaries.

Also applies to: 123-123


309-311: LGTM!

The participant validation checks are correctly applied to both blockPartner and unblockPartner. Additionally, returning blocked=true when a user is already blocked (line 321) is more semantically accurate than the previous false value.

Also applies to: 317-321, 346-349


372-393: LGTM!

The getBlockStatus method correctly validates chat participation, resolves the partner ID, and queries block status in both directions. The implementation follows the established patterns in this service.

Removed 'iBlockedPartner' field from ChatDtos class.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/main/java/com/salemale/domain/chat/dto/ChatDtos.java (1)

53-56: Previous critical issue resolved; consider idiomatic naming.

The field is now correctly declared inside the ChatSummaryResponse class body, fixing the compilation error flagged in the previous review.

The iBlockedPartner naming is unconventional—Java boolean fields typically use prefixes like is, has, or can (e.g., hasBlockedPartner or isPartnerBlocked). However, the current naming is functional and the comments clearly explain the semantics.

If you prefer a more idiomatic convention, consider renaming to hasBlockedPartner:

-        // 내가 이 대화 상대를 차단했는지 여부
-        // true  -> 이미 차단됨
-        // false -> 차단 안 됨
-        private boolean iBlockedPartner;
+        // 내가 이 대화 상대를 차단했는지 여부
+        // true  -> 이미 차단됨
+        // false -> 차단 안 됨
+        private boolean hasBlockedPartner;

Note: This would require updating references in the service layer and API responses.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between de2e6e0 and 1aa551d.

📒 Files selected for processing (1)
  • src/main/java/com/salemale/domain/chat/dto/ChatDtos.java (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (1)
src/main/java/com/salemale/domain/chat/dto/ChatDtos.java (1)

28-28: LGTM: formatting adjustment.

The whitespace change has no functional impact.

@e2guana e2guana requested a review from Judonguk December 13, 2025 14:13
@e2guana e2guana merged commit 0149872 into dev Dec 13, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨FEAT 기능 구현 관련 🔨RAFACTOR 리팩토링 관련

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants