Add a Publisher abstraction and queued job to publish from the UI
Introduce Publisher/PublisherManager (WordPress + Reddit implementations) so publishing logic is shared between the CLI, the queue, and future network integrations. Add a "Publish" button on the Posts page that dispatches PublishPostJob instead of blocking the request — Reddit's publisher shells out to the existing Playwright sidecar and can take tens of seconds, so it can't run synchronously in a web request. Adds a `target` field (e.g. subreddit) and `publishing` status to Post, plus a `publish_error` field so failures surface in the UI. Refactors posts:publish to delegate to WordPressPublisher without changing its CLI output contract (existing tests pass unchanged). Also fixes two bugs found along the way: UpdatePostRequest was silently dropping `published_url` from PATCH requests (never in its validation rules, despite AI_API.md documenting it), and three Livewire index-page tests were broken by the earlier auth change (never re-run after adding the `auth` middleware) since they hit routes via HTTP without a logged-in user. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,7 @@ class StorePostRequest extends FormRequest
|
||||
'type' => ['required', 'string', 'in:' . implode(',', Post::TYPES)],
|
||||
'title' => ['nullable', 'string', 'max:255'],
|
||||
'body' => ['required', 'string'],
|
||||
'target' => ['nullable', 'string', 'max:255'],
|
||||
'status' => ['sometimes', 'string', 'in:' . implode(',', Post::STATUSES)],
|
||||
'scheduled_at' => ['nullable', 'date'],
|
||||
];
|
||||
|
||||
@@ -20,8 +20,10 @@ class UpdatePostRequest extends FormRequest
|
||||
'type' => ['sometimes', 'required', 'string', 'in:' . implode(',', Post::TYPES)],
|
||||
'title' => ['nullable', 'string', 'max:255'],
|
||||
'body' => ['sometimes', 'required', 'string'],
|
||||
'target' => ['nullable', 'string', 'max:255'],
|
||||
'status' => ['sometimes', 'string', 'in:' . implode(',', Post::STATUSES)],
|
||||
'scheduled_at' => ['nullable', 'date'],
|
||||
'published_url' => ['nullable', 'string', 'max:255'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,11 @@ class PostResource extends JsonResource
|
||||
'type' => $this->type,
|
||||
'title' => $this->title,
|
||||
'body' => $this->body,
|
||||
'target' => $this->target,
|
||||
'status' => $this->status,
|
||||
'scheduled_at' => $this->scheduled_at,
|
||||
'published_url' => $this->published_url,
|
||||
'publish_error' => $this->publish_error,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user