Skip to content

Commit

Permalink
refactor: 차단 API 자신은 차단하지 못하도록 변경 (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
its-sky committed Sep 6, 2024
1 parent f4dfc18 commit 2cf3012
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import com.depromeet.type.ErrorType;

public enum BlacklistErrorType implements ErrorType {
ALREADY_BLACKED("BLACK_1", "이미 차단한 사용자입니다");
ALREADY_BLACKED("BLACK_1", "이미 차단한 사용자입니다"),
CANNOT_BLACK_MYSELF("BLACK_2", "자기 자신을 차단할 수 없습니다");

private final String code;
private final String message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public class BlacklistFacade {

public void blackMember(Long memberId, BlackMemberRequest request) {
Long blackMemberId = request.blackMemberId();
if (memberId.equals(blackMemberId)) {
throw new BadRequestException(BlacklistErrorType.CANNOT_BLACK_MYSELF);
}

boolean isAlreadyBlacked = blacklistQueryUseCase.checkBlackMember(memberId, blackMemberId);
if (isAlreadyBlacked) {
throw new BadRequestException(BlacklistErrorType.ALREADY_BLACKED);
Expand Down

0 comments on commit 2cf3012

Please sign in to comment.