fix: incorrect results when filtering unpublished posts (#4736)

#### What type of PR is this?
/kind bug
/area core
/milestone 2.10.x

#### What this PR does / why we need it:
修复筛选未发布文章时结果不正确的问题

#### Which issue(s) this PR fixes:
Fixes #4730 

#### Does this PR introduce a user-facing change?
```release-note
修复筛选未发布文章时结果不正确的问题
```
pull/4772/head
guqing 2023-10-23 16:13:24 +08:00 committed by GitHub
parent 772c7fcf97
commit baca058bb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -13,6 +13,7 @@ import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup;
import org.springframework.context.ApplicationEvent;
@ -102,6 +103,10 @@ public class PostReconciler implements Reconciler<Reconciler.Request> {
post.getMetadata().setAnnotations(annotations);
}
if (!annotations.containsKey(Post.PUBLISHED_LABEL)) {
labels.put(Post.PUBLISHED_LABEL, BooleanUtils.FALSE);
}
var status = post.getStatus();
if (status == null) {
status = new Post.PostStatus();