Skip to content

Blocking Feature Implementation - #413

Merged
Whale0928 merged 16 commits into
devfrom
feat/block
Jul 1, 2025
Merged

Blocking Feature Implementation#413
Whale0928 merged 16 commits into
devfrom
feat/block

Conversation

@Whale0928

Copy link
Copy Markdown
Collaborator

This pull request introduces a comprehensive blocking feature to the application, enabling user-specific content filtering based on block relationships. Key changes include the implementation of annotations for filtering, a custom serializer for blocked content, and APIs for managing block relationships. Additionally, caching and exception handling have been integrated to optimize and secure the feature.

Blocking Feature Implementation:

  • Guide Documentation: Added BLOCK_FEATURE_USAGE.md to provide detailed instructions on using the blocking feature, including annotations, AOP aspects, and sample implementations.
  • Custom Annotation: Introduced @BlockWord in src/main/java/app/bottlenote/common/block/annotation/BlockWord.java to replace blocked user content with a predefined message during JSON serialization.
  • Custom Serializer: Developed BlockWordSerializer in src/main/java/app/bottlenote/common/block/serializer/BlockWordSerializer.java to handle the logic for blocked content replacement.

API and Domain Enhancements:

  • Block Management API: Added BlockController in src/main/java/app/bottlenote/support/block/controller/BlockController.java to support blocking, unblocking, and retrieving blocked user lists.
  • Domain Model: Created UserBlock entity in src/main/java/app/bottlenote/support/block/domain/UserBlock.java to represent block relationships in the database.

Caching and Testing:

  • Local Cache: Extended LocalCacheType in src/main/java/app/bottlenote/global/cache/local/LocalCacheType.java to include caching for blocked users.
  • Testing: Added HTTP test cases in http/block/차단_필터링_테스트.http to verify the blocking functionality.

Exception Handling:

  • Custom Exceptions: Implemented BlockException and BlockExceptionCode in src/main/java/app/bottlenote/support/block/exception to handle block-related errors with appropriate HTTP status codes. [1] [2]

Integration with Existing Features:

  • Review Content Filtering: Applied @BlockWord annotation to reviewContent in ReviewInfo and nickName in UserInfo to filter blocked user content in reviews. [1] [2]

…ation and AOP support

Signed-off-by: hgkim <hgkim@openerd.com>
… and related services

Signed-off-by: hgkim <hgkim@openerd.com>
Copilot AI review requested due to automatic review settings June 27, 2025 03:58
@Whale0928
Whale0928 marked this pull request as draft June 27, 2025 03:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request implements a comprehensive blocking feature for user content filtering by introducing custom annotations, serializers, APIs, and caching enhancements while also updating documentation and tests.

  • Introduces a new @blockword annotation and accompanying serializer for content filtering.
  • Adds API endpoints and services to manage block relationships along with caching and exception handling.
  • Updates documentation and test cases to guide usage and integration of the feature.

Reviewed Changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/main/resources/application-logging.yml Adds debug logging for block components.
src/main/java/app/bottlenote/support/block/service/BlockService.java Implements block/unblock logic and caching for block relationships.
src/main/java/app/bottlenote/support/block/repository/JpaUserBlockRepository.java Provides JPA repository methods for block data, including a custom query for mutual blocks.
src/main/java/app/bottlenote/global/security/SecurityContextUtil.java Extends context handling to support testing scenarios via a custom authentication token.
src/main/java/app/bottlenote/common/block/serializer/BlockWordSerializer.java Implements the serializer for @blockword with dynamic user ID extraction via reflection.
src/main/java/app/bottlenote/common/block/annotation/BlockWord.java Defines the custom annotation used to trigger content filtering in JSON serialization.
Documentation Files Update guides and usage examples for the blocking feature, including block implementation and testing instructions.
Comments suppressed due to low confidence (2)

src/main/java/app/bottlenote/support/block/repository/JpaUserBlockRepository.java:32

  • Consider rewriting the query to use an explicit CASE expression (e.g., 'CASE WHEN COUNT(ub) = 2 THEN true ELSE false END') to ensure greater compatibility across JPA providers.
    @Query("SELECT COUNT(ub) = 2 FROM userBlock ub " +

BLOCK_FEATURE_USAGE.md:6

  • [nitpick] The documentation references a BlockFilter annotation in a different package; update this to reflect the actual annotation location (app.bottlenote.common.block.annotation.BlockWord) to avoid confusion.
- **위치**: `app.bottlenote.global.annotation.BlockFilter`

Object principal = authentication.getPrincipal();

// 테스트 환경에서 TestingAuthenticationToken 지원
if (authentication.getClass().getSimpleName().equals("TestingAuthenticationToken")) {

Copilot AI Jun 27, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] Using class name string comparison can be brittle; consider using an 'instanceof' check (if the TestingAuthenticationToken type is accessible) to improve maintainability.

Copilot uses AI. Check for mistakes.
Signed-off-by: hgkim <hgkim@openerd.com>
Signed-off-by: hgkim <hgkim@openerd.com>
…tion

Signed-off-by: hgkim <hgkim@openerd.com>
Signed-off-by: hgkim <hgkim@openerd.com>
…pendency injection

Signed-off-by: hgkim <hgkim@openerd.com>
…e tests

Signed-off-by: hgkim <hgkim@openerd.com>
Signed-off-by: hgkim <hgkim@openerd.com>
…tems and rename test tasks

Signed-off-by: hgkim <hgkim@openerd.com>
…adability

Signed-off-by: hgkim <hgkim@openerd.com>
…rder

Signed-off-by: hgkim <hgkim@openerd.com>
Signed-off-by: hgkim <hgkim@openerd.com>
@sonarqubecloud

sonarqubecloud Bot commented Jul 1, 2025

Copy link
Copy Markdown

@Whale0928
Whale0928 marked this pull request as ready for review July 1, 2025 13:23
@Whale0928
Whale0928 merged commit 30baac6 into dev Jul 1, 2025
3 checks passed
@Whale0928
Whale0928 deleted the feat/block branch July 1, 2025 13:23
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.

3 participants