find($this->postId); if (! $post) { return; } // A duplicate/stale job for a post already resolved by an earlier // run of this same job (e.g. a double-dispatch while no worker was // running) — skip it rather than risk publishing twice. if ($post->status !== 'publishing') { return; } $publisher = $publishers->resolve($post); if (! $publisher) { $post->update(['status' => 'draft', 'publish_error' => "No publisher available for post type '{$post->type}'."]); return; } $result = $publisher->publish($post); if ($result->success) { $post->update(['status' => 'published', 'published_url' => $result->url, 'publish_error' => null]); return; } $post->update([ 'status' => $result->attempted ? 'failed' : 'draft', 'publish_error' => $result->error, ]); Log::error('post publish failed', ['post_id' => $post->id, 'error' => $result->error]); } }