Skip to content

Commit

Permalink
user 이미지 url앞에 bucket url prefix가 중복으로 붙는 문제 해결 (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
juno-junho authored Jan 27, 2024
1 parent 0131945 commit 2e5918d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static CommentResponse of(CommentInfo commentInfo, String bucketUrl) {
commentInfo.content(),
commentInfo.authorId(),
commentInfo.author(),
commentInfo.authorImageUrl() == null ? null : bucketUrl + commentInfo.authorImageUrl(),
commentInfo.authorImageUrl(),
commentInfo.createdDate(),
commentInfo.lastModifiedDate(),
commentInfo.isPrivate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public static PostResponse from(PostInfo postInfo, String bucketUrl) {
postInfo.content(),
postInfo.authorId(),
postInfo.author(),
postInfo.authorImageUrl() == null ? null : bucketUrl + postInfo.authorImageUrl(),
postInfo.postImageUrl() == null ? null : bucketUrl + postInfo.postImageUrl(),
postInfo.authorImageUrl(),
postInfo.postImageUrl(bucketUrl),
postInfo.createdDate(),
postInfo.lastModifiedDate()
);
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/spaceclub/board/service/vo/PostInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,12 @@ public static PostInfo of(Post post, UserProfile userProfile) {
post.getLastModifiedAt()
);
}

public String postImageUrl(String bucketUrl) {
if (postImageUrl == null) {
return null;
}
return bucketUrl + postImageUrl;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class CommentControllerTest {
.andExpect(jsonPath("$.content").value(comment.getContent()))
.andExpect(jsonPath("$.authorId").value(comment.getAuthorId()))
.andExpect(jsonPath("$.author").value(userProfile.username()))
.andExpect(jsonPath("$.authorImageUrl").value(bucketUrl + userProfile.profileImageUrl()))
.andExpect(jsonPath("$.authorImageUrl").value(userProfile.profileImageUrl()))
.andExpect(jsonPath("$.createdDate").value("2024-01-01T00:00:00"))
.andExpect(jsonPath("$.lastModifiedDate").value("2024-01-01T00:00:00"))
.andExpect(jsonPath("$.isPrivate").value(comment.isPrivate()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class PostControllerTest {
.andExpect(jsonPath("$.content").value(post.getContent()))
.andExpect(jsonPath("$.authorId").value(post.getAuthorId()))
.andExpect(jsonPath("$.author").value(userProfile.username()))
.andExpect(jsonPath("$.authorImageUrl").value(bucketUrl + userProfile.profileImageUrl()))
.andExpect(jsonPath("$.authorImageUrl").value(userProfile.profileImageUrl()))
.andExpect(jsonPath("$.postImageUrl").value(bucketUrl + post.getPostImageUrl()))
.andExpect(jsonPath("$.createdDate").value("2024-01-01T00:00:00"))
.andExpect(jsonPath("$.lastModifiedDate").value("2024-01-01T00:00:00"))
Expand Down

0 comments on commit 2e5918d

Please sign in to comment.