mirror of https://github.com/halo-dev/halo
feat: add approvedTime for comment and reply (#2746)
#### What type of PR is this? /kind feature /milestone 2.0.0-rc.1 /kind api-change /area core #### What this PR does / why we need it: 评论和回复新增 approvedTime 属性 1. 此属性在创建时如果是不需要审核就公开的则会填充当前时间 2. 目前没有审核功能,审核是 Console 端去更新的 approved 字段,因此需要更新 approved 时判断有没有设置 approvedTime 没有则填充当前时间,后续有审核功能后则再由后端处理 #### Which issue(s) this PR fixes: Fixes #2738 #### Special notes for your reviewer: /cc @halo-dev/sig-halo #### Does this PR introduce a user-facing change? ```release-note 评论和回复新增 approvedTime 属性 ```pull/2745/head
parent
0df7857ef8
commit
21c18d4b9a
|
@ -2,10 +2,12 @@ package run.halo.app.content.comment;
|
||||||
|
|
||||||
import static run.halo.app.extension.router.selector.SelectorUtil.labelAndFieldSelectorToPredicate;
|
import static run.halo.app.extension.router.selector.SelectorUtil.labelAndFieldSelectorToPredicate;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.security.core.context.ReactiveSecurityContextHolder;
|
import org.springframework.security.core.context.ReactiveSecurityContextHolder;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
@ -81,6 +83,10 @@ public class CommentServiceImpl implements CommentService {
|
||||||
}
|
}
|
||||||
comment.getSpec()
|
comment.getSpec()
|
||||||
.setApproved(Boolean.FALSE.equals(commentSetting.getRequireReviewForNew()));
|
.setApproved(Boolean.FALSE.equals(commentSetting.getRequireReviewForNew()));
|
||||||
|
if (BooleanUtils.isTrue(comment.getSpec().getApproved())
|
||||||
|
&& comment.getSpec().getApprovedTime() == null) {
|
||||||
|
comment.getSpec().setApprovedTime(Instant.now());
|
||||||
|
}
|
||||||
comment.getSpec().setHidden(false);
|
comment.getSpec().setHidden(false);
|
||||||
if (comment.getSpec().getOwner() != null) {
|
if (comment.getSpec().getOwner() != null) {
|
||||||
return Mono.just(comment);
|
return Mono.just(comment);
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.time.Instant;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
import org.springframework.security.core.context.ReactiveSecurityContextHolder;
|
import org.springframework.security.core.context.ReactiveSecurityContextHolder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
|
@ -62,6 +63,11 @@ public class ReplyServiceImpl implements ReplyService {
|
||||||
reply.getSpec().setApproved(
|
reply.getSpec().setApproved(
|
||||||
Boolean.FALSE.equals(commentSetting.getRequireReviewForNew()));
|
Boolean.FALSE.equals(commentSetting.getRequireReviewForNew()));
|
||||||
reply.getSpec().setHidden(!reply.getSpec().getApproved());
|
reply.getSpec().setHidden(!reply.getSpec().getApproved());
|
||||||
|
|
||||||
|
if (BooleanUtils.isTrue(reply.getSpec().getApproved())
|
||||||
|
&& reply.getSpec().getApprovedTime() == null) {
|
||||||
|
reply.getSpec().setApprovedTime(Instant.now());
|
||||||
|
}
|
||||||
return reply;
|
return reply;
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
|
@ -65,6 +65,8 @@ public class Comment extends AbstractExtension {
|
||||||
|
|
||||||
private String ipAddress;
|
private String ipAddress;
|
||||||
|
|
||||||
|
private Instant approvedTime;
|
||||||
|
|
||||||
@Schema(required = true, defaultValue = "0")
|
@Schema(required = true, defaultValue = "0")
|
||||||
private Integer priority;
|
private Integer priority;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue