Posts get a nullable image_url. WordPressPublisher now downloads it and uploads it to WordPress's media endpoint before creating the post, setting it as featured_media — and rejects publishing (without touching status) if a blog post has no image set, mirroring the existing title requirement. Every other network treats it as optional. Not enforced at save time, same as title — you can still draft an incomplete WordPress post, it just can't be published until an image is set. Exposed through the UI form (with a thumbnail/""missing"" indicator in the table), the JSON API, and the Python CLI wrapper. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
30 lines
898 B
PHP
30 lines
898 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use App\Models\Post;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class StorePostRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'site_id' => ['required', 'integer', 'exists:sites,id'],
|
|
'social_account_id' => ['nullable', 'integer', 'exists:social_accounts,id'],
|
|
'type' => ['required', 'string', 'in:' . implode(',', Post::TYPES)],
|
|
'title' => ['nullable', 'string', 'max:255'],
|
|
'body' => ['required', 'string'],
|
|
'target' => ['nullable', 'string', 'max:255'],
|
|
'image_url' => ['nullable', 'url', 'max:2048'],
|
|
'status' => ['sometimes', 'string', 'in:' . implode(',', Post::STATUSES)],
|
|
'scheduled_at' => ['nullable', 'date'],
|
|
];
|
|
}
|
|
}
|