Phase 8 (Rest) + Umbauten vom 10./11.06.: - Ein Titelbild pro PM (Cover 1280x580), SVG-Platzhalter-Set + Picker, PressReleaseCoverImage-Resolver - Lizenz-/Rechteformular nach "Lizenztyp Bildupload" (7 Lizenztypen, Personen-/Sachrechte-Status, bedingte Pflichtfelder, Risikohinweise) - Veroeffentlichungs-Box vereinfacht (Embargo aus der Form-UI entfernt), geplante Termine in Europe/Berlin (Speicherung UTC, DISPLAY_TIMEZONE) - Quota-Stub (users.press_release_quota) + monatlicher Reset-Command - Einreichungs-Modal einheitlich in Show/Create/Edit; Ghost-Buttons auf filled; PM-Editor-Layout responsive entkoppelt (.pr-editor-layout) KI-Pruef-Pipeline (Phasen 1-5 des Entwicklungsplans): - API-Haertung: status nicht mehr per API setzbar, eigene Submit-Route durch denselben Funnel (Blacklist, Quota, Status-Log) - Klassifikation Rot/Gelb/Gruen asynchron (Queue classification, OpenAI-Treiber + deterministischer Fallback), ki_audits-Audit-Log - Routing: Rot -> rejected + Mail, Gelb -> Review-Queue, Gruen -> Auto-Publish; Scheduler publiziert nur gruene faellige PMs - Content-Score 0-100 -> Stufe (Standard/Geprueft/Hochwertig) inkl. Editor-Panel und Badges; Re-Klassifikation/-Score bei Aenderung - Admin: KI-Badge + Filter, On-Demand-Pruefung mit Anbieter-Override Suite: 442 passed, 4 skipped. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
112 lines
3.5 KiB
PHP
112 lines
3.5 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Enums\PressReleaseClassification;
|
|
use App\Enums\PressReleaseStatus;
|
|
use App\Models\PressRelease;
|
|
use App\Services\PressRelease\BlacklistViolationException;
|
|
use App\Services\PressRelease\PressReleaseService;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Str;
|
|
use Throwable;
|
|
|
|
/**
|
|
* Veröffentlicht Pressemitteilungen mit Status `review`, der KI-Klassifikation
|
|
* `green` und einem `scheduled_at`-Zeitpunkt, der erreicht/überschritten wurde.
|
|
*
|
|
* Läuft regelmäßig per Scheduler (siehe routes/console.php). Idempotent:
|
|
* berührt nur grüne PRs in Review-Status — bereits publishte werden ignoriert.
|
|
* Gelb eingestufte PMs bleiben bewusst in der manuellen Admin-Queue, auch wenn
|
|
* ihr Termin fällig ist.
|
|
*
|
|
* Blacklist-Treffer landen wie beim manuellen Publish im Reject-Status mit
|
|
* Mail-Benachrichtigung des Autors.
|
|
*/
|
|
class PublishScheduledPressReleases extends Command
|
|
{
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $signature = 'press-releases:publish-scheduled
|
|
{--dry-run : Nur anzeigen, was publiziert würde, ohne DB zu ändern}
|
|
{--limit=200 : Maximale Anzahl pro Lauf}';
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $description = 'Veröffentlicht fällige geplante Pressemitteilungen (Status review + scheduled_at <= now).';
|
|
|
|
public function handle(PressReleaseService $service): int
|
|
{
|
|
$dryRun = (bool) $this->option('dry-run');
|
|
$limit = max(1, (int) $this->option('limit'));
|
|
|
|
$now = now();
|
|
|
|
$candidates = PressRelease::withoutGlobalScopes()
|
|
->where('status', PressReleaseStatus::Review->value)
|
|
->where('classification', PressReleaseClassification::Green->value)
|
|
->whereNotNull('scheduled_at')
|
|
->where('scheduled_at', '<=', $now)
|
|
->orderBy('scheduled_at')
|
|
->limit($limit)
|
|
->get();
|
|
|
|
if ($candidates->isEmpty()) {
|
|
$this->info('Keine fälligen geplanten Pressemitteilungen gefunden.');
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
|
|
$this->info(sprintf(
|
|
'%d fällige Pressemitteilung(en) gefunden.%s',
|
|
$candidates->count(),
|
|
$dryRun ? ' (Dry-Run)' : '',
|
|
));
|
|
|
|
$published = 0;
|
|
$rejected = 0;
|
|
$failed = 0;
|
|
|
|
foreach ($candidates as $pressRelease) {
|
|
$line = sprintf(
|
|
' #%d scheduled_at=%s title="%s"',
|
|
$pressRelease->id,
|
|
$pressRelease->scheduled_at?->format('Y-m-d H:i') ?? '-',
|
|
Str::limit($pressRelease->title, 60),
|
|
);
|
|
|
|
if ($dryRun) {
|
|
$this->line($line.' [DRY]');
|
|
|
|
continue;
|
|
}
|
|
|
|
try {
|
|
$service->publish($pressRelease, source: 'scheduler');
|
|
$published++;
|
|
$this->line($line.' [OK]');
|
|
} catch (BlacklistViolationException $e) {
|
|
$rejected++;
|
|
$this->warn($line.' [REJECT: '.$e->word.']');
|
|
} catch (Throwable $e) {
|
|
$failed++;
|
|
$this->error($line.' [FAIL: '.$e->getMessage().']');
|
|
report($e);
|
|
}
|
|
}
|
|
|
|
if (! $dryRun) {
|
|
$this->newLine();
|
|
$this->info(sprintf(
|
|
'Fertig: %d veröffentlicht, %d wegen Blacklist abgelehnt, %d fehlgeschlagen.',
|
|
$published,
|
|
$rejected,
|
|
$failed,
|
|
));
|
|
}
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|