- archive_entries (append-only) + archive_access_log; Disk archive außerhalb des Web-Roots; eigener ARCHIVE_KEY (archive:key), AES-256-CBC, SHA-256 am Eintrag - EvidenceArchive: record/open/manifest/export (signiertes ZIP), setLegalHold/releaseLegalHold (Frist läuft neu), purgeDue, exportTombstones, reconcileAfterRestore - PressReleaseArchiver: image_removed (Original, Snapshot, Bestätigungen), pm_depublished (letzter veröffentlichter Stand), gdpr_change (Anonymisierung, Korrekturen), label_corrected - Hooks in Remover, depublish/archive/changeStatusFromAdmin/deleteFromAdmin, AnonymizationService, CorrectionService, ImageCorrectionService - Scheduler archive:purge 03:20 und archive:export-tombstones 03:30; archive:reconcile-after-restore im Runbook - Admin ▸ Management ▸ Beweisarchiv (Liste, Legal Hold mit Pflichtvermerk, Öffnen/Export nur mit Zweck) - Scope-Wächter: neue Befehle nutzen withoutGlobalScope(PortalScope::class) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
88 lines
3.2 KiB
PHP
88 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace App\Services\PressRelease\Images;
|
|
|
|
use App\Enums\ArchiveEvent;
|
|
use App\Enums\ArchiveReasonCategory;
|
|
use App\Models\PressReleaseImage;
|
|
use App\Models\User;
|
|
use App\Services\Archive\PressReleaseArchiver;
|
|
use App\Services\Image\ImageService;
|
|
use App\Support\WebCaches;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
/**
|
|
* Entfernt ein Titelbild (Bildkennzeichnung E.3, Decision-Update E4):
|
|
*
|
|
* - nie veröffentlicht: Derivate, Original, Snapshot und Bestätigung sofort
|
|
* und vollständig weg, die Zeile wird hart gelöscht;
|
|
* - veröffentlicht: Derivate weg, Zeile weich gelöscht; Original, Snapshot
|
|
* und Bestätigung bleiben für das Beweisarchiv (Block F übernimmt die
|
|
* Überführung und die Frist).
|
|
*
|
|
* Bestand ohne `rules_version` hat weder Original noch Protokoll und wird
|
|
* wie bisher behandelt (Derivate weg, Soft Delete).
|
|
*/
|
|
class PressReleaseImageRemover
|
|
{
|
|
public function __construct(
|
|
private readonly ImageService $imageService,
|
|
private readonly PressReleaseArchiver $archiver,
|
|
) {}
|
|
|
|
public function remove(PressReleaseImage $image, ?User $actor = null, ArchiveEvent $event = ArchiveEvent::ImageRemoved, ArchiveReasonCategory $reason = ArchiveReasonCategory::CustomerRequest): void
|
|
{
|
|
$this->imageService->deletePressReleaseImage($image->disk, $image->path, $image->variants);
|
|
|
|
if ($image->wasEverPublished() || $image->isLegacyRules()) {
|
|
// Veröffentlicht: Original, Snapshot und Bestätigungen ins
|
|
// Beweisarchiv (Block F), danach die lokalen Beweisdateien weg.
|
|
if ($image->wasEverPublished() && ! $image->isLegacyRules()) {
|
|
$entry = $this->archiver->imageRemoved($image, $actor, $event, $reason);
|
|
|
|
if ($entry !== null) {
|
|
$this->deleteEvidenceFiles($image);
|
|
}
|
|
}
|
|
|
|
$image->delete();
|
|
WebCaches::forgetPublicPages();
|
|
|
|
return;
|
|
}
|
|
|
|
DB::transaction(function () use ($image): void {
|
|
foreach ($image->rightsConfirmations()->get() as $confirmation) {
|
|
$confirmation->purgeForUnpublished();
|
|
}
|
|
|
|
if ($image->original_path !== null) {
|
|
Storage::disk($image->original_disk ?? (string) config('images.originals_disk'))->delete($image->original_path);
|
|
}
|
|
|
|
if ($image->published_snapshot_path !== null) {
|
|
Storage::disk($image->original_disk ?? (string) config('images.originals_disk'))->delete($image->published_snapshot_path);
|
|
}
|
|
|
|
$image->forceDelete();
|
|
});
|
|
}
|
|
|
|
private function deleteEvidenceFiles(PressReleaseImage $image): void
|
|
{
|
|
$disk = Storage::disk($image->original_disk ?? (string) config('images.originals_disk'));
|
|
|
|
foreach (array_filter([$image->original_path, $image->published_snapshot_path]) as $path) {
|
|
$disk->delete($path);
|
|
}
|
|
|
|
if ($image->published_snapshot_path !== null) {
|
|
$sidecar = preg_replace('/\.[a-z0-9]+$/i', '.json', $image->published_snapshot_path);
|
|
|
|
if (is_string($sidecar)) {
|
|
$disk->delete($sidecar);
|
|
}
|
|
}
|
|
}
|
|
}
|