Skip to content

Commit

Permalink
fix: ImageUrl null 체크검증 (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbscks97 authored Aug 24, 2024
1 parent 7b78ae4 commit fd1cb65
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public ImageUrlResponse uploadCompleteMemberProfile(
currentMember.getId(),
image.getImageKey(),
request.imageFileExtension());

isValidImageUrl(imageUrl);
currentMember.updateProfile(Profile.createProfile(request.nickname(), imageUrl));
return ImageUrlResponse.of(imageUrl);
}
Expand Down Expand Up @@ -138,6 +140,7 @@ public ImageUrlResponse uploadCompleteMissionRecord(MissionRecordImageUploadRequ
image.getImageKey(),
request.imageFileExtension());

isValidImageUrl(imageUrl);
missionRecordService.updateMissionRecordWithImage(request.recordId(), imageUrl);
return ImageUrlResponse.of(imageUrl);
}
Expand Down Expand Up @@ -177,6 +180,7 @@ public ImageUrlResponse uploadCompleteMission(MissionImageUploadRequest request)
image.getImageKey(),
request.imageFileExtension());

isValidImageUrl(imageUrl);
missionService.updateMissionWithImageUrl(request.missionId(), imageUrl);

return ImageUrlResponse.of(imageUrl);
Expand Down Expand Up @@ -250,4 +254,10 @@ private GeneratePresignedUrlRequest createPreSignedUrlRequest(
private Date getPreSignedUrlExpiration() {
return new Date(System.currentTimeMillis() + 1000 * 60 * 30);
}

private void isValidImageUrl(String imageUrl) {
if (imageUrl == null || imageUrl.trim().isEmpty()) {
throw new CustomException(ErrorCode.INVALID_IMAGE_URL);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public enum ErrorCode {
IMAGE_FILE_EXTENSION_NOT_FOUND(HttpStatus.NOT_FOUND, "이미지 파일 확장자를 찾을 수 없습니다."),
INVALID_IMAGE_FILE_EXTENSION(HttpStatus.BAD_REQUEST, "올바른 이미지 확장자가 아닙니다."),
MEMBER_ALREADY_DELETED(HttpStatus.CONFLICT, "이미 탈퇴한 회원입니다."),
INVALID_IMAGE_URL(HttpStatus.BAD_REQUEST, "올바른 이미지 URL이 아닙니다."),

// follow
FOLLOW_SELF_NOT_ALLOWED(HttpStatus.CONFLICT, "본인은 팔로우 할 수 없습니다."),
Expand Down

0 comments on commit fd1cb65

Please sign in to comment.