From a9af3c78bf2ff694c19c5d20170141a328430c67 Mon Sep 17 00:00:00 2001 From: yhc <876680538@qq.com> Date: Thu, 21 Apr 2022 18:41:36 +0800 Subject: [PATCH 1/6] Fixed the bug of not being able to query according to the content The content table is associated at query time now. --- .../run/halo/app/service/impl/PostServiceImpl.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/run/halo/app/service/impl/PostServiceImpl.java b/src/main/java/run/halo/app/service/impl/PostServiceImpl.java index 646ec712cf..4ba2a96c90 100644 --- a/src/main/java/run/halo/app/service/impl/PostServiceImpl.java +++ b/src/main/java/run/halo/app/service/impl/PostServiceImpl.java @@ -544,6 +544,8 @@ public Post removeById(Integer postId) { * @param postQuery post query must not be null * @return a post specification */ + + // CS304 issue: https://github.com/halo-dev/halo/issues/1842 @NonNull private Specification buildSpecByQuery(@NonNull PostQuery postQuery) { Assert.notNull(postQuery, "Post query must not be null"); @@ -572,16 +574,21 @@ private Specification buildSpecByQuery(@NonNull PostQuery postQuery) { } if (postQuery.getKeyword() != null) { + // Format like condition String likeCondition = String .format("%%%s%%", StringUtils.strip(postQuery.getKeyword())); // Build like predicate + Subquery postSubquery = query.subquery(Post.class); + Root contentRoot = postSubquery.from(Content.class); + postSubquery.select(contentRoot.get("id")) + .where(criteriaBuilder.like(contentRoot.get("originalContent"), likeCondition)); + Predicate titleLike = criteriaBuilder.like(root.get("title"), likeCondition); - Predicate originalContentLike = criteriaBuilder - .like(root.get("originalContent"), likeCondition); - predicates.add(criteriaBuilder.or(titleLike, originalContentLike)); + predicates.add( + criteriaBuilder.or(titleLike, criteriaBuilder.in(root).value(postSubquery))); } return query.where(predicates.toArray(new Predicate[0])).getRestriction(); From 395deec1a6de283988de36ab2972eb6d7c9b982d Mon Sep 17 00:00:00 2001 From: yhc <876680538@qq.com> Date: Sat, 30 Apr 2022 17:55:37 +0800 Subject: [PATCH 2/6] Update static file mappings on refresh --- .../halo/app/service/impl/StaticStorageServiceImpl.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/run/halo/app/service/impl/StaticStorageServiceImpl.java b/src/main/java/run/halo/app/service/impl/StaticStorageServiceImpl.java index 341406f0ad..1e1367ced9 100644 --- a/src/main/java/run/halo/app/service/impl/StaticStorageServiceImpl.java +++ b/src/main/java/run/halo/app/service/impl/StaticStorageServiceImpl.java @@ -53,7 +53,12 @@ public StaticStorageServiceImpl(HaloProperties haloProperties, @Override public List listStaticFolder() { - return listStaticFileTree(staticDir); + + List staticFiles = listStaticFileTree(staticDir); + + onChange(); // To update the mapping of local files. + + return staticFiles; } @Nullable From 4e76b1632e829f35b84bd43b0f3572386f981356 Mon Sep 17 00:00:00 2001 From: yhc <876680538@qq.com> Date: Tue, 17 May 2022 23:17:57 +0800 Subject: [PATCH 3/6] feat:add more parameter in mail template --- .../comment/CommentEventListener.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/main/java/run/halo/app/listener/comment/CommentEventListener.java b/src/main/java/run/halo/app/listener/comment/CommentEventListener.java index 779233afb2..867deedc49 100644 --- a/src/main/java/run/halo/app/listener/comment/CommentEventListener.java +++ b/src/main/java/run/halo/app/listener/comment/CommentEventListener.java @@ -126,6 +126,11 @@ public void handleCommentNewEvent(CommentNewEvent newEvent) { data.put("pageTitle", post.getTitle()); data.put("author", postComment.getAuthor()); data.put("content", postComment.getContent()); + data.put("email", postComment.getEmail()); + data.put("ip", postComment.getIpAddress()); + data.put("status", postComment.getStatus()); + data.put("time", postComment.getCreateTime()); + data.put("authorUrl", postComment.getAuthorUrl()); subject.append("您的博客文章《") .append(post.getTitle()) @@ -144,6 +149,11 @@ public void handleCommentNewEvent(CommentNewEvent newEvent) { data.put("pageTitle", sheet.getTitle()); data.put("author", sheetComment.getAuthor()); data.put("content", sheetComment.getContent()); + data.put("email", sheetComment.getEmail()); + data.put("ip", sheetComment.getIpAddress()); + data.put("status", sheetComment.getStatus()); + data.put("time", sheetComment.getCreateTime()); + data.put("authorUrl", sheetComment.getAuthorUrl()); subject.append("您的博客页面《") .append(sheet.getTitle()) @@ -162,6 +172,11 @@ public void handleCommentNewEvent(CommentNewEvent newEvent) { data.put("pageTitle", journal.getCreateTime()); data.put("author", journalComment.getAuthor()); data.put("content", journalComment.getContent()); + data.put("email", journalComment.getEmail()); + data.put("ip", journalComment.getIpAddress()); + data.put("status", journalComment.getStatus()); + data.put("time", journalComment.getCreateTime()); + data.put("authorUrl", journalComment.getAuthorUrl()); subject.append("您的博客日志有了新的评论"); } @@ -230,6 +245,10 @@ public void handleCommentReplyEvent(CommentReplyEvent replyEvent) { data.put("baseContent", baseComment.getContent()); data.put("replyAuthor", postComment.getAuthor()); data.put("replyContent", postComment.getContent()); + data.put("baseAuthorEmail", baseComment.getEmail()); + data.put("replyAuthorEmail", postComment.getEmail()); + data.put("time", postComment.getCreateTime()); + data.put("authorUrl", postComment.getAuthorUrl()); subject.append("您在【") .append(blogTitle) @@ -263,6 +282,10 @@ public void handleCommentReplyEvent(CommentReplyEvent replyEvent) { data.put("baseContent", baseComment.getContent()); data.put("replyAuthor", sheetComment.getAuthor()); data.put("replyContent", sheetComment.getContent()); + data.put("baseAuthorEmail", baseComment.getEmail()); + data.put("replyAuthorEmail", sheetComment.getEmail()); + data.put("time", sheetComment.getCreateTime()); + data.put("authorUrl", sheetComment.getAuthorUrl()); subject.append("您在【") .append(blogTitle) @@ -298,6 +321,10 @@ public void handleCommentReplyEvent(CommentReplyEvent replyEvent) { data.put("baseContent", baseComment.getContent()); data.put("replyAuthor", journalComment.getAuthor()); data.put("replyContent", journalComment.getContent()); + data.put("baseAuthorEmail", baseComment.getEmail()); + data.put("replyAuthorEmail", journalComment.getEmail()); + data.put("time", journalComment.getCreateTime()); + data.put("authorUrl", journalComment.getAuthorUrl()); subject.append("您在【") .append(blogTitle) From d42a638cba701e4a8eae6f8df1aa493e08800c99 Mon Sep 17 00:00:00 2001 From: yhc <876680538@qq.com> Date: Wed, 18 May 2022 12:29:36 +0800 Subject: [PATCH 4/6] Update CommentEventListener.java --- .../comment/CommentEventListener.java | 54 ++++--------------- 1 file changed, 9 insertions(+), 45 deletions(-) diff --git a/src/main/java/run/halo/app/listener/comment/CommentEventListener.java b/src/main/java/run/halo/app/listener/comment/CommentEventListener.java index 867deedc49..717481dc00 100644 --- a/src/main/java/run/halo/app/listener/comment/CommentEventListener.java +++ b/src/main/java/run/halo/app/listener/comment/CommentEventListener.java @@ -124,13 +124,7 @@ public void handleCommentNewEvent(CommentNewEvent newEvent) { data.put("pageFullPath", enabledAbsolutePath ? post.getFullPath() : optionService.getBlogBaseUrl() + post.getFullPath()); data.put("pageTitle", post.getTitle()); - data.put("author", postComment.getAuthor()); - data.put("content", postComment.getContent()); - data.put("email", postComment.getEmail()); - data.put("ip", postComment.getIpAddress()); - data.put("status", postComment.getStatus()); - data.put("time", postComment.getCreateTime()); - data.put("authorUrl", postComment.getAuthorUrl()); + data.put("comment", postComment); subject.append("您的博客文章《") .append(post.getTitle()) @@ -147,13 +141,7 @@ public void handleCommentNewEvent(CommentNewEvent newEvent) { data.put("pageFullPath", enabledAbsolutePath ? sheet.getFullPath() : optionService.getBlogBaseUrl() + sheet.getFullPath()); data.put("pageTitle", sheet.getTitle()); - data.put("author", sheetComment.getAuthor()); - data.put("content", sheetComment.getContent()); - data.put("email", sheetComment.getEmail()); - data.put("ip", sheetComment.getIpAddress()); - data.put("status", sheetComment.getStatus()); - data.put("time", sheetComment.getCreateTime()); - data.put("authorUrl", sheetComment.getAuthorUrl()); + data.put("comment", sheetComment); subject.append("您的博客页面《") .append(sheet.getTitle()) @@ -170,13 +158,7 @@ public void handleCommentNewEvent(CommentNewEvent newEvent) { .append(optionService.getJournalsPrefix()); data.put("pageFullPath", url); data.put("pageTitle", journal.getCreateTime()); - data.put("author", journalComment.getAuthor()); - data.put("content", journalComment.getContent()); - data.put("email", journalComment.getEmail()); - data.put("ip", journalComment.getIpAddress()); - data.put("status", journalComment.getStatus()); - data.put("time", journalComment.getCreateTime()); - data.put("authorUrl", journalComment.getAuthorUrl()); + data.put("comment", journalComment); subject.append("您的博客日志有了新的评论"); } @@ -241,14 +223,8 @@ public void handleCommentReplyEvent(CommentReplyEvent replyEvent) { data.put("pageFullPath", enabledAbsolutePath ? post.getFullPath() : optionService.getBlogBaseUrl() + post.getFullPath()); data.put("pageTitle", post.getTitle()); - data.put("baseAuthor", baseComment.getAuthor()); - data.put("baseContent", baseComment.getContent()); - data.put("replyAuthor", postComment.getAuthor()); - data.put("replyContent", postComment.getContent()); - data.put("baseAuthorEmail", baseComment.getEmail()); - data.put("replyAuthorEmail", postComment.getEmail()); - data.put("time", postComment.getCreateTime()); - data.put("authorUrl", postComment.getAuthorUrl()); + data.put("baseComment", baseComment); + data.put("replyComment", postComment); subject.append("您在【") .append(blogTitle) @@ -278,14 +254,8 @@ public void handleCommentReplyEvent(CommentReplyEvent replyEvent) { data.put("pageFullPath", enabledAbsolutePath ? sheet.getFullPath() : optionService.getBlogBaseUrl() + sheet.getFullPath()); data.put("pageTitle", sheet.getTitle()); - data.put("baseAuthor", baseComment.getAuthor()); - data.put("baseContent", baseComment.getContent()); - data.put("replyAuthor", sheetComment.getAuthor()); - data.put("replyContent", sheetComment.getContent()); - data.put("baseAuthorEmail", baseComment.getEmail()); - data.put("replyAuthorEmail", sheetComment.getEmail()); - data.put("time", sheetComment.getCreateTime()); - data.put("authorUrl", sheetComment.getAuthorUrl()); + data.put("baseComment", baseComment); + data.put("replyComment", sheetComment); subject.append("您在【") .append(blogTitle) @@ -317,14 +287,8 @@ public void handleCommentReplyEvent(CommentReplyEvent replyEvent) { .append(optionService.getJournalsPrefix()); data.put("pageFullPath", url); data.put("pageTitle", journal.getContent()); - data.put("baseAuthor", baseComment.getAuthor()); - data.put("baseContent", baseComment.getContent()); - data.put("replyAuthor", journalComment.getAuthor()); - data.put("replyContent", journalComment.getContent()); - data.put("baseAuthorEmail", baseComment.getEmail()); - data.put("replyAuthorEmail", journalComment.getEmail()); - data.put("time", journalComment.getCreateTime()); - data.put("authorUrl", journalComment.getAuthorUrl()); + data.put("baseComment", baseComment); + data.put("replyComment", journalComment); subject.append("您在【") .append(blogTitle) From d3d3df85f36f29f406b61e1eb35d25ccdbe9ee16 Mon Sep 17 00:00:00 2001 From: yhc <876680538@qq.com> Date: Wed, 18 May 2022 12:48:30 +0800 Subject: [PATCH 5/6] Update CommentEventListener.java --- .../comment/CommentEventListener.java | 51 +++++++++++++++---- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/src/main/java/run/halo/app/listener/comment/CommentEventListener.java b/src/main/java/run/halo/app/listener/comment/CommentEventListener.java index 717481dc00..98fa064480 100644 --- a/src/main/java/run/halo/app/listener/comment/CommentEventListener.java +++ b/src/main/java/run/halo/app/listener/comment/CommentEventListener.java @@ -124,7 +124,12 @@ public void handleCommentNewEvent(CommentNewEvent newEvent) { data.put("pageFullPath", enabledAbsolutePath ? post.getFullPath() : optionService.getBlogBaseUrl() + post.getFullPath()); data.put("pageTitle", post.getTitle()); - data.put("comment", postComment); + data.put("author", postComment.getAuthor()); + data.put("content", postComment.getContent()); + data.put("email", postComment.getEmail()); + data.put("status", postComment.getStatus()); + data.put("time", postComment.getCreateTime()); + data.put("authorUrl", postComment.getAuthorUrl()); subject.append("您的博客文章《") .append(post.getTitle()) @@ -141,7 +146,12 @@ public void handleCommentNewEvent(CommentNewEvent newEvent) { data.put("pageFullPath", enabledAbsolutePath ? sheet.getFullPath() : optionService.getBlogBaseUrl() + sheet.getFullPath()); data.put("pageTitle", sheet.getTitle()); - data.put("comment", sheetComment); + data.put("author", sheetComment.getAuthor()); + data.put("content", sheetComment.getContent()); + data.put("email", sheetComment.getEmail()); + data.put("status", sheetComment.getStatus()); + data.put("time", sheetComment.getCreateTime()); + data.put("authorUrl", sheetComment.getAuthorUrl()); subject.append("您的博客页面《") .append(sheet.getTitle()) @@ -158,7 +168,12 @@ public void handleCommentNewEvent(CommentNewEvent newEvent) { .append(optionService.getJournalsPrefix()); data.put("pageFullPath", url); data.put("pageTitle", journal.getCreateTime()); - data.put("comment", journalComment); + data.put("author", journalComment.getAuthor()); + data.put("content", journalComment.getContent()); + data.put("email", journalComment.getEmail()); + data.put("status", journalComment.getStatus()); + data.put("time", journalComment.getCreateTime()); + data.put("authorUrl", journalComment.getAuthorUrl()); subject.append("您的博客日志有了新的评论"); } @@ -223,8 +238,14 @@ public void handleCommentReplyEvent(CommentReplyEvent replyEvent) { data.put("pageFullPath", enabledAbsolutePath ? post.getFullPath() : optionService.getBlogBaseUrl() + post.getFullPath()); data.put("pageTitle", post.getTitle()); - data.put("baseComment", baseComment); - data.put("replyComment", postComment); + data.put("baseAuthor", baseComment.getAuthor()); + data.put("baseContent", baseComment.getContent()); + data.put("replyAuthor", postComment.getAuthor()); + data.put("replyContent", postComment.getContent()); + data.put("baseAuthorEmail", baseComment.getEmail()); + data.put("replyAuthorEmail", postComment.getEmail()); + data.put("time", postComment.getCreateTime()); + data.put("authorUrl", postComment.getAuthorUrl()); subject.append("您在【") .append(blogTitle) @@ -254,8 +275,14 @@ public void handleCommentReplyEvent(CommentReplyEvent replyEvent) { data.put("pageFullPath", enabledAbsolutePath ? sheet.getFullPath() : optionService.getBlogBaseUrl() + sheet.getFullPath()); data.put("pageTitle", sheet.getTitle()); - data.put("baseComment", baseComment); - data.put("replyComment", sheetComment); + data.put("baseAuthor", baseComment.getAuthor()); + data.put("baseContent", baseComment.getContent()); + data.put("replyAuthor", sheetComment.getAuthor()); + data.put("replyContent", sheetComment.getContent()); + data.put("baseAuthorEmail", baseComment.getEmail()); + data.put("replyAuthorEmail", sheetComment.getEmail()); + data.put("time", sheetComment.getCreateTime()); + data.put("authorUrl", sheetComment.getAuthorUrl()); subject.append("您在【") .append(blogTitle) @@ -287,8 +314,14 @@ public void handleCommentReplyEvent(CommentReplyEvent replyEvent) { .append(optionService.getJournalsPrefix()); data.put("pageFullPath", url); data.put("pageTitle", journal.getContent()); - data.put("baseComment", baseComment); - data.put("replyComment", journalComment); + data.put("baseAuthor", baseComment.getAuthor()); + data.put("baseContent", baseComment.getContent()); + data.put("replyAuthor", journalComment.getAuthor()); + data.put("replyContent", journalComment.getContent()); + data.put("baseAuthorEmail", baseComment.getEmail()); + data.put("replyAuthorEmail", journalComment.getEmail()); + data.put("time", journalComment.getCreateTime()); + data.put("authorUrl", journalComment.getAuthorUrl()); subject.append("您在【") .append(blogTitle) From 8b373baedb139050f4f22721718062a32f1c95fd Mon Sep 17 00:00:00 2001 From: yhc <876680538@qq.com> Date: Wed, 18 May 2022 14:37:11 +0800 Subject: [PATCH 6/6] Update CommentEventListener.java --- .../app/listener/comment/CommentEventListener.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/run/halo/app/listener/comment/CommentEventListener.java b/src/main/java/run/halo/app/listener/comment/CommentEventListener.java index 98fa064480..7965f2c4c5 100644 --- a/src/main/java/run/halo/app/listener/comment/CommentEventListener.java +++ b/src/main/java/run/halo/app/listener/comment/CommentEventListener.java @@ -128,7 +128,7 @@ public void handleCommentNewEvent(CommentNewEvent newEvent) { data.put("content", postComment.getContent()); data.put("email", postComment.getEmail()); data.put("status", postComment.getStatus()); - data.put("time", postComment.getCreateTime()); + data.put("createTime", postComment.getCreateTime()); data.put("authorUrl", postComment.getAuthorUrl()); subject.append("您的博客文章《") @@ -150,7 +150,7 @@ public void handleCommentNewEvent(CommentNewEvent newEvent) { data.put("content", sheetComment.getContent()); data.put("email", sheetComment.getEmail()); data.put("status", sheetComment.getStatus()); - data.put("time", sheetComment.getCreateTime()); + data.put("createTime", sheetComment.getCreateTime()); data.put("authorUrl", sheetComment.getAuthorUrl()); subject.append("您的博客页面《") @@ -172,7 +172,7 @@ public void handleCommentNewEvent(CommentNewEvent newEvent) { data.put("content", journalComment.getContent()); data.put("email", journalComment.getEmail()); data.put("status", journalComment.getStatus()); - data.put("time", journalComment.getCreateTime()); + data.put("createTime", journalComment.getCreateTime()); data.put("authorUrl", journalComment.getAuthorUrl()); subject.append("您的博客日志有了新的评论"); @@ -244,7 +244,7 @@ public void handleCommentReplyEvent(CommentReplyEvent replyEvent) { data.put("replyContent", postComment.getContent()); data.put("baseAuthorEmail", baseComment.getEmail()); data.put("replyAuthorEmail", postComment.getEmail()); - data.put("time", postComment.getCreateTime()); + data.put("createTime", postComment.getCreateTime()); data.put("authorUrl", postComment.getAuthorUrl()); subject.append("您在【") @@ -281,7 +281,7 @@ public void handleCommentReplyEvent(CommentReplyEvent replyEvent) { data.put("replyContent", sheetComment.getContent()); data.put("baseAuthorEmail", baseComment.getEmail()); data.put("replyAuthorEmail", sheetComment.getEmail()); - data.put("time", sheetComment.getCreateTime()); + data.put("createTime", sheetComment.getCreateTime()); data.put("authorUrl", sheetComment.getAuthorUrl()); subject.append("您在【") @@ -320,7 +320,7 @@ public void handleCommentReplyEvent(CommentReplyEvent replyEvent) { data.put("replyContent", journalComment.getContent()); data.put("baseAuthorEmail", baseComment.getEmail()); data.put("replyAuthorEmail", journalComment.getEmail()); - data.put("time", journalComment.getCreateTime()); + data.put("createTime", journalComment.getCreateTime()); data.put("authorUrl", journalComment.getAuthorUrl()); subject.append("您在【")