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(
PhoenixKit.Modules.Posts.ScheduledPostHandler,
post.uuid,
~U[2025-01-15 10:00:00Z]
)Behavior
When executed:
- Loads the post by ID
- Calls
Posts.publish_post/1to change status to "public" - Returns
:okon 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}