diff --git a/application/src/main/java/run/halo/app/core/extension/reconciler/PostReconciler.java b/application/src/main/java/run/halo/app/core/extension/reconciler/PostReconciler.java index eb182a51a7..fafdd67a2c 100644 --- a/application/src/main/java/run/halo/app/core/extension/reconciler/PostReconciler.java +++ b/application/src/main/java/run/halo/app/core/extension/reconciler/PostReconciler.java @@ -113,6 +113,10 @@ public Result reconcile(Request request) { post.setStatus(status); } + if (post.isPublished() && post.getSpec().getPublishTime() == null) { + post.getSpec().setPublishTime(Instant.now()); + } + // calculate the sha256sum var configSha256sum = Hashing.sha256().hashString(post.getSpec().toString(), UTF_8) .toString(); diff --git a/application/src/main/java/run/halo/app/core/extension/reconciler/SinglePageReconciler.java b/application/src/main/java/run/halo/app/core/extension/reconciler/SinglePageReconciler.java index 441d95dae6..ad46213b5e 100644 --- a/application/src/main/java/run/halo/app/core/extension/reconciler/SinglePageReconciler.java +++ b/application/src/main/java/run/halo/app/core/extension/reconciler/SinglePageReconciler.java @@ -112,6 +112,10 @@ void subscribeNewCommentNotification(SinglePage page) { private void reconcileSpec(String name) { client.fetch(SinglePage.class, name).ifPresent(page -> { + if (page.isPublished() && page.getSpec().getPublishTime() == null) { + page.getSpec().setPublishTime(Instant.now()); + } + // un-publish if necessary if (page.isPublished() && Objects.equals(false, page.getSpec().getPublish())) { unPublish(name);