feat(wordpress): store suggested publish date directly in WP draft

Reserve the publish slot before creating the WP draft so the
scheduled_publish_at timestamp is available when building the post
payload. WordPress receives the `date` field (e.g. 2026-03-24T09:00:00)
which sets the scheduled publish time on the draft.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OliverGiertz 2026-03-21 11:15:39 +00:00
parent e9c472b722
commit 970f509ad4
2 changed files with 11 additions and 5 deletions

View file

@ -276,16 +276,16 @@ def _process_article(article: dict[str, Any], stats: PipelineStats, settings: An
else:
# Auto-process: rewrite + WP draft
try:
# Reload article to get updated image_review
# Reserve publish slot FIRST so it's available when WP draft is created
slot = reserve_publish_slot(article_id)
# Reload article to get updated image_review + scheduled_publish_at
fresh = get_article_by_id(article_id)
if not fresh:
return
wp_post_id, wp_post_url = _do_rewrite_and_draft(fresh)
stats.drafts_created += 1
# Reserve publish slot
slot = reserve_publish_slot(article_id)
# Reload for notification
final = get_article_by_id(article_id)
if final:
@ -357,8 +357,11 @@ def override_rejected_article(article_id: int) -> None:
except Exception:
score = 0
wp_post_id, wp_post_url = _do_rewrite_and_draft(fresh)
# Reserve publish slot FIRST so it's in the DB when WP draft is created
slot = reserve_publish_slot(article_id)
fresh = get_article_by_id(article_id)
wp_post_id, wp_post_url = _do_rewrite_and_draft(fresh)
final = get_article_by_id(article_id)
if final:

View file

@ -335,6 +335,9 @@ def publish_article_draft(article: dict[str, Any]) -> tuple[int, str | None]:
payload["excerpt"] = excerpt
if featured_media_id:
payload["featured_media"] = featured_media_id
scheduled_at = article.get("scheduled_publish_at")
if scheduled_at:
payload["date"] = scheduled_at # e.g. "2026-03-24T09:00:00"
wp_post_id = article.get("wp_post_id")
tag_ids = _resolve_wp_tag_ids(