From d3c91fff6e8d9d9b644b31136af3a1a5eceec360 Mon Sep 17 00:00:00 2001 From: gracefulBrown Date: Wed, 29 May 2024 13:57:16 +0900 Subject: [PATCH] =?UTF-8?q?fix(article):=20rss=20=EB=A1=9C=EB=94=A9=20?= =?UTF-8?q?=EC=98=A4=EB=9E=98=EA=B1=B8=EB=A6=BC=20=EC=9D=B4=EC=8A=88=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../article/application/SlackService.java | 2 +- .../prolog/article/domain/Article.java | 18 +++++-- .../prolog/article/domain/Description.java | 4 ++ .../prolog/article/domain/ImageUrl.java | 2 +- .../wooteco/prolog/article/domain/Title.java | 3 +- .../prod/V10__create_column_rssfeed.sql | 3 ++ .../ProfilePageSideBar/ProfilePageSideBar.tsx | 50 +++++++++---------- 7 files changed, 49 insertions(+), 33 deletions(-) diff --git a/backend/src/main/java/wooteco/prolog/article/application/SlackService.java b/backend/src/main/java/wooteco/prolog/article/application/SlackService.java index b82ad43b1..8aaf47126 100644 --- a/backend/src/main/java/wooteco/prolog/article/application/SlackService.java +++ b/backend/src/main/java/wooteco/prolog/article/application/SlackService.java @@ -57,7 +57,7 @@ public void sendSlackMessage(Article article) { // Context block String name = article.getMember().getNickname() + "(" + article.getMember().getUsername() + ")"; - String date = article.getCreatedAt().toLocalDate().toString(); + String date = article.getPublishedAt().toLocalDate().toString(); ContextBlock contextBlock = ContextBlock.builder() .elements(Collections.singletonList( MarkdownTextObject.builder() diff --git a/backend/src/main/java/wooteco/prolog/article/domain/Article.java b/backend/src/main/java/wooteco/prolog/article/domain/Article.java index 737711881..4ce915dea 100644 --- a/backend/src/main/java/wooteco/prolog/article/domain/Article.java +++ b/backend/src/main/java/wooteco/prolog/article/domain/Article.java @@ -11,6 +11,7 @@ import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.member.domain.Member; +import javax.persistence.Column; import javax.persistence.Embedded; import javax.persistence.Entity; import javax.persistence.EntityListeners; @@ -21,6 +22,7 @@ import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import java.time.LocalDateTime; +import java.time.ZoneId; import static java.lang.Boolean.TRUE; @@ -50,6 +52,9 @@ public class Article { @Embedded private ImageUrl imageUrl; + @Column + private LocalDateTime publishedAt; + @Embedded private ArticleBookmarks articleBookmarks; @@ -62,17 +67,21 @@ public class Article { @Embedded private ViewCount views; + public Article(Member member, Title title, Description description, Url url, ImageUrl imageUrl) { + this(member, title, description, url, imageUrl, null); + } public Article(Member member, Title title, Url url, ImageUrl imageUrl) { - this(member, title, new Description(), url, imageUrl); + this(member, title, new Description(), url, imageUrl, null); } - public Article(Member member, Title title, Description description, Url url, ImageUrl imageUrl) { + public Article(Member member, Title title, Description description, Url url, ImageUrl imageUrl, LocalDateTime publishedAt) { this.member = member; this.title = title; this.description = description; this.url = url; this.imageUrl = imageUrl; + this.publishedAt = publishedAt; this.articleBookmarks = new ArticleBookmarks(); this.articleLikes = new ArticleLikes(); this.views = new ViewCount(); @@ -80,10 +89,11 @@ public Article(Member member, Title title, Description description, Url url, Ima public static Article of(Member member, SyndFeed syndFeed, SyndEntry entry) { Title title = new Title(entry.getTitle()); - Description description = new Description(entry.getDescription().getValue()); ImageUrl imageUrl = ImageUrl.of(entry.getDescription().getValue(), syndFeed.getImage().getUrl()); + Description description = new Description(entry.getDescription().getValue()); + LocalDateTime publishedAt = entry.getPublishedDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); - return new Article(member, title, description, new Url(entry.getLink()), imageUrl); + return new Article(member, title, description, new Url(entry.getLink()), imageUrl, publishedAt); } public void validateOwner(final Member member) { diff --git a/backend/src/main/java/wooteco/prolog/article/domain/Description.java b/backend/src/main/java/wooteco/prolog/article/domain/Description.java index 4804e46bc..f1f4f1e0b 100644 --- a/backend/src/main/java/wooteco/prolog/article/domain/Description.java +++ b/backend/src/main/java/wooteco/prolog/article/domain/Description.java @@ -23,6 +23,10 @@ public Description(String description) { if (description == null || description.isEmpty() || description.trim().isEmpty()) { description = "내용없음"; } + if (description.length() > 100) { + description = description.substring(0, 100); + } + this.description = StringEscapeUtils.unescapeHtml4(Jsoup.clean(description, Safelist.none())); } } diff --git a/backend/src/main/java/wooteco/prolog/article/domain/ImageUrl.java b/backend/src/main/java/wooteco/prolog/article/domain/ImageUrl.java index bf838d5ad..7538d0621 100644 --- a/backend/src/main/java/wooteco/prolog/article/domain/ImageUrl.java +++ b/backend/src/main/java/wooteco/prolog/article/domain/ImageUrl.java @@ -29,7 +29,7 @@ public ImageUrl(String url) { if (Objects.isNull(url) || url.isEmpty() || url.trim().isEmpty() || url.length() > MAX_LENGTH) { url = "https://avatars.githubusercontent.com/u/45747236?s=200&v=4"; } - this.url = url.trim(); + this.url = url; } public static ImageUrl of(String description, String defaultUrl) { diff --git a/backend/src/main/java/wooteco/prolog/article/domain/Title.java b/backend/src/main/java/wooteco/prolog/article/domain/Title.java index 7c3acdfe2..028ca45e1 100644 --- a/backend/src/main/java/wooteco/prolog/article/domain/Title.java +++ b/backend/src/main/java/wooteco/prolog/article/domain/Title.java @@ -32,8 +32,7 @@ public Title(String title) { if (title.length() > MAX_LENGTH) { title = title.substring(0, MAX_LENGTH); } - title = StringEscapeUtils.unescapeHtml4(Jsoup.clean(title, Safelist.none())); - this.title = title; + this.title = title.trim(); } } diff --git a/backend/src/main/resources/db/migration/prod/V10__create_column_rssfeed.sql b/backend/src/main/resources/db/migration/prod/V10__create_column_rssfeed.sql index 963198cfc..6a7758b2f 100644 --- a/backend/src/main/resources/db/migration/prod/V10__create_column_rssfeed.sql +++ b/backend/src/main/resources/db/migration/prod/V10__create_column_rssfeed.sql @@ -3,3 +3,6 @@ ALTER TABLE member ALTER TABLE article ADD COLUMN description VARCHAR(256) AFTER title; + +ALTER TABLE article + ADD COLUMN published_at datetime(6) AFTER image_url; diff --git a/frontend/src/components/ProfilePageSideBar/ProfilePageSideBar.tsx b/frontend/src/components/ProfilePageSideBar/ProfilePageSideBar.tsx index 48e5c7d10..592d42808 100644 --- a/frontend/src/components/ProfilePageSideBar/ProfilePageSideBar.tsx +++ b/frontend/src/components/ProfilePageSideBar/ProfilePageSideBar.tsx @@ -114,31 +114,31 @@ const ProfilePageSideBar = ({ menu }: ProfilePageSideBarProps) => { )} - {/*RSS Link*/} - {/**/} - {/* {isRssFeedEditing ? (*/} - {/* setRssFeedUrl(target.value)}*/} - {/* />*/} - {/* ) : (*/} - {/* {rssFeedUrl}*/} - {/* )}*/} - {/* {isOwner && (*/} - {/* {*/} - {/* isRssFeedEditing ? editProfile() : setIsRssFeedEditing(true);*/} - {/* }}*/} - {/* >*/} - {/* {isRssFeedEditing ? '완료' : '수정'}*/} - {/* */} - {/* )}*/} - {/**/} + RSS Link + + {isRssFeedEditing ? ( + setRssFeedUrl(target.value)} + /> + ) : ( + {rssFeedUrl} + )} + {isOwner && ( + + )} + {isLoading ? <> : }