Skip to content

Commit

Permalink
fix: Prevent private posts from being indexed when rebuilding index.
Browse files Browse the repository at this point in the history
  • Loading branch information
AirboZH committed Nov 21, 2023
1 parent fbc9045 commit 801525d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ public static boolean isPublished(MetadataOperator metadata) {
return labels != null && parseBoolean(labels.getOrDefault(PUBLISHED_LABEL, "false"));
}

public static boolean isVisible(PostSpec spec) {
return VisibleEnum.PUBLIC.equals(spec.getVisible());
}

@Data
public static class PostSpec {
@Schema(requiredMode = RequiredMode.REQUIRED, minLength = 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public Mono<Void> rebuildPostIndices() {

private Mono<Void> rebuildPostIndices(PostSearchService searchService) {
return postFinder.listAll()
.filter(post -> Post.isPublished(post.getMetadata()))
.filter(
post -> Post.isPublished(post.getMetadata()) && Post.isVisible(post.getSpec()))
.flatMap(listedPostVo -> {
PostVo postVo = PostVo.from(listedPostVo);
return postFinder.content(postVo.getMetadata().getName())
Expand Down

0 comments on commit 801525d

Please sign in to comment.