PhoenixKitPosts.ScheduledPostHandler (PhoenixKitPosts v0.1.3)

Copy Markdown View Source

Handler for scheduled post publishing.

This handler is called by the scheduled jobs system to publish posts that have reached their scheduled publish time.

Usage

Schedule a post for publishing:

ScheduledJobs.schedule_job(
  PhoenixKitPosts.ScheduledPostHandler,
  post.uuid,
  ~U[2025-01-15 10:00:00Z]
)

Behavior

When executed:

  1. Loads the post by ID
  2. Calls PhoenixKitPosts.publish_post/1 to change status to "public"
  3. Returns :ok on success, {:error, reason} on failure

Error Cases

  • Post not found: Returns {:error, :not_found}
  • Post already published: Still calls publish_post (idempotent)
  • Database error: Returns {:error, changeset}