- B-01/B-02: Startseiten-Feed, Card-Helfer und Nachweis-PDF nur mit isPubliclyDeliverable() - B-03: Livewire-Temp-Upload 16 MiB - N09: Snapshot je Bytes- und Metadaten-Hash inkl. OG-Variante, put() geprüft, alle Fassungen ins Archiv - O03: published_ever_at in der Freigabetransaktion (markPublishedIfNowPublic) — Kundenbestätigung, Vorab-Sichtung, Korrektur - B-04/B-14: Bestätigung an Bild-ID und SHA gebunden, unter Sperre - B-05/B-06: Entfernen unter Sperre mit frischem Stand und Archivauftrag; Korrektur archiviert über den Auftrag, Nacharbeiten abgesichert - B-07: precheck_withheld_at getrennt von withheld_at (Migration + Übernahme) - B-08, B-09, B-11, B-12: published_ever_at nur bei Status published, Admin-Eigentümer mit Kundenregel, Sweep verwaister Originale, Verarbeitungsfehler als Formularmeldung - K-02-Teil: nach Kundenbestätigung erneut routen - OPT-3 bis OPT-5: pingImage für JPEG, Hash durchgereicht, erstes Frame Admin-PM-Detailseite enthält zusätzlich K-06 (Autorisierung) und A-08 (Nachweis per POST), weil die Datei ungeteilt committet ist. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
99 lines
3.4 KiB
PHP
99 lines
3.4 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Image\Precheck;
|
|
|
|
use App\Enums\ArchiveEvent;
|
|
use App\Enums\ArchiveReasonCategory;
|
|
use App\Enums\PressReleaseStatus;
|
|
use App\Models\KiAudit;
|
|
use App\Models\PressReleaseImage;
|
|
use App\Models\User;
|
|
use App\Services\PressRelease\Images\PressReleaseImageRemover;
|
|
use App\Services\PressRelease\Images\PublishedImageSnapshot;
|
|
use App\Support\WebCaches;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Throwable;
|
|
|
|
/**
|
|
* Admin-Queue des Vorab-Checks (DU 12.3, 12.5): Ein Bild mit Ausgang
|
|
* `queue` ist zurückgehalten, bis ein Mensch entscheidet. Freigabe macht es
|
|
* sichtbar, Ablehnung entfernt es; beides mit Vermerk im KI-Protokoll und
|
|
* am Bild.
|
|
*/
|
|
class ImagePrecheckReviewService
|
|
{
|
|
public function __construct(
|
|
private readonly PressReleaseImageRemover $remover,
|
|
private readonly PublishedImageSnapshot $snapshots,
|
|
) {}
|
|
|
|
public function approve(PressReleaseImage $image, User $admin, string $note): void
|
|
{
|
|
DB::transaction(function () use ($image, $admin, $note): void {
|
|
$image->forceFill([
|
|
'precheck_reviewed_at' => now(),
|
|
'precheck_reviewed_by' => $admin->getKey(),
|
|
'precheck_review_note' => $note,
|
|
// Nur der eigene Grund fällt (Umsetzungsaudit 29.09., B-07):
|
|
// ein Rückhalt aus dem Korrekturweg bleibt bestehen.
|
|
'precheck_withheld_at' => null,
|
|
])->save();
|
|
$image->markPublishedIfNowPublic();
|
|
|
|
$this->audit($image, 'approved', $note);
|
|
});
|
|
|
|
$pressRelease = $image->pressRelease;
|
|
|
|
if ($pressRelease?->status === PressReleaseStatus::Published && $image->isPubliclyDeliverable()) {
|
|
// Jetzt erst öffentlich: Veröffentlichungssnapshot (N09) nach
|
|
// dem N08-Muster — Fehler werden gemeldet, nicht geworfen.
|
|
try {
|
|
$this->snapshots->capture($image, $pressRelease);
|
|
} catch (Throwable $exception) {
|
|
report($exception);
|
|
}
|
|
}
|
|
|
|
if ($pressRelease?->published_at !== null) {
|
|
try {
|
|
WebCaches::forgetPublicPages();
|
|
} catch (Throwable $exception) {
|
|
report($exception);
|
|
}
|
|
}
|
|
}
|
|
|
|
public function reject(PressReleaseImage $image, User $admin, string $note): void
|
|
{
|
|
DB::transaction(function () use ($image, $admin, $note): void {
|
|
$image->forceFill([
|
|
'precheck_reviewed_at' => now(),
|
|
'precheck_reviewed_by' => $admin->getKey(),
|
|
'precheck_review_note' => $note,
|
|
])->save();
|
|
|
|
$this->audit($image, 'rejected', $note);
|
|
});
|
|
|
|
$this->remover->remove($image, $admin, ArchiveEvent::ImageRemoved, ArchiveReasonCategory::OwnDecision);
|
|
}
|
|
|
|
private function audit(PressReleaseImage $image, string $decision, string $note): void
|
|
{
|
|
KiAudit::query()->create([
|
|
'press_release_id' => $image->press_release_id,
|
|
'type' => KiAudit::TYPE_IMAGE_PRECHECK_REVIEW,
|
|
'provider' => 'admin',
|
|
'model' => null,
|
|
'result' => $decision,
|
|
'reason' => $note,
|
|
'raw_response' => [
|
|
'image_id' => $image->getKey(),
|
|
'reviewed_by' => $image->precheck_reviewed_by,
|
|
'precheck' => $image->precheck,
|
|
],
|
|
'created_at' => now(),
|
|
]);
|
|
}
|
|
}
|