recht: Meldeverfahren v2 Phasen 1-4 — Re-Sync-Sperre, Anonymisierung, Magic-Link-Intake, Self-Service-Korrektur
Phase 1: sync_locked_at auf press_releases (Importer überspringt gesperrte PMs auch bei --force), LegalRequest um Verifikation/Ausführung erweitert, verschlüsselte Vorher-Snapshots mit Löschfrist (snapshots:purge, täglich). Phase 2: AnonymizationService (Unicode-Wortgrenzen-Schwärzung, Pflicht-Diff, transaktionale Ausführung mit Snapshot, Kontakt-Detach, Bild-Löschung, Sitemap-Invalidierung, Verlauf ohne Klartext-Altwerte); Admin-Queue kann DSGVO-Anfragen anonymisieren oder depublizieren, inkl. Snapshot-Restore. Phase 3: Deflektions-Trichter „PM melden/ändern" (melden/pm) mit Kosten- Tabelle vorab; Magic-Link geht nur an die hinterlegte Pressekontaktadresse (neuer purpose press_release_report), atomare Verifikation, Anliegen-Auswahl erzeugt verifizierte Queue-Anfragen; toter-Kanal-Fallback; Owner-Einstieg. Phase 4: Panel-Abschnitt „Änderung & Korrektur" — Levenshtein-Gate (5 %, Mini-Edit-Ausnahme ≤ 2 Zeichen) stuft klein/groß ein; kleine Korrektur kostenlos sofort live (Snapshot, Sperre, Verlauf, Re-Score), größere als Change-Anfrage (Interim bis 10-€-Checkout, Phase 7). Entwicklungsplan mit Entscheidungen E1-E8 und offenen Punkten in docs/Decision-Update; 41 Pest-Tests (tests/Feature/Legal) grün. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
58c0cc3f23
commit
b4b2e013d6
42 changed files with 3868 additions and 1 deletions
|
|
@ -4,11 +4,13 @@ namespace App\Models;
|
|||
|
||||
use App\Enums\LegalRequestStatus;
|
||||
use App\Enums\LegalRequestType;
|
||||
use App\Enums\LegalRequestVerificationMethod;
|
||||
use Database\Factories\LegalRequestFactory;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* Rechts-/Compliance-Anfrage (WS-3) – DSGVO, Persönlichkeitsrecht oder Meldung.
|
||||
|
|
@ -29,9 +31,13 @@ class LegalRequest extends Model
|
|||
'message',
|
||||
'payload',
|
||||
'requester_ip',
|
||||
'verified_at',
|
||||
'verification_method',
|
||||
'single_purchase_id',
|
||||
'resolved_by_user_id',
|
||||
'admin_note',
|
||||
'resolved_at',
|
||||
'executed_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
|
|
@ -40,7 +46,10 @@ class LegalRequest extends Model
|
|||
'type' => LegalRequestType::class,
|
||||
'status' => LegalRequestStatus::class,
|
||||
'payload' => 'array',
|
||||
'verified_at' => 'datetime',
|
||||
'verification_method' => LegalRequestVerificationMethod::class,
|
||||
'resolved_at' => 'datetime',
|
||||
'executed_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -80,6 +89,23 @@ class LegalRequest extends Model
|
|||
return $this->belongsTo(User::class, 'resolved_by_user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Bezahlvorgang der kostenpflichtigen Spuren (Depublizierung/Änderung).
|
||||
*/
|
||||
public function singlePurchase(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(SinglePurchase::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verschlüsselte Vorher-Snapshots ausgeführter Mutationen (Korrektur/
|
||||
* Anonymisierung) — Grundlage der Rückgängig-Option bis zur Löschfrist.
|
||||
*/
|
||||
public function redactionSnapshots(): HasMany
|
||||
{
|
||||
return $this->hasMany(PressReleaseRedactionSnapshot::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder<LegalRequest> $query
|
||||
* @return Builder<LegalRequest>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\ActivityType;
|
||||
use App\Enums\AiTextDeclaration;
|
||||
use App\Enums\BoostPlacement;
|
||||
use App\Enums\Portal;
|
||||
|
|
@ -13,6 +14,7 @@ use App\Enums\PressReleaseStatus;
|
|||
use App\Http\Middleware\SetEdition;
|
||||
use App\Models\Concerns\HasUniqueSlug;
|
||||
use App\Scopes\PortalScope;
|
||||
use App\Services\ActivityLog;
|
||||
use App\Services\PressRelease\PressReleaseHtmlSanitizer;
|
||||
use Closure;
|
||||
use Database\Factories\PressReleaseFactory;
|
||||
|
|
@ -115,6 +117,7 @@ class PressRelease extends Model
|
|||
'no_export' => 'boolean',
|
||||
'published_at' => 'datetime',
|
||||
'depublished_at' => 'datetime',
|
||||
'sync_locked_at' => 'datetime',
|
||||
'scheduled_at' => 'datetime',
|
||||
'embargo_at' => 'datetime',
|
||||
'withdrawal_waiver_consented_at' => 'datetime',
|
||||
|
|
@ -131,6 +134,58 @@ class PressRelease extends Model
|
|||
return $this->scheduled_at;
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-Sync-Sperre (Meldeverfahren): Nach einer Mutation über das
|
||||
* Meldeverfahren darf kein Legacy-Import/API-Re-Sync die PM mehr
|
||||
* überschreiben — sonst kommt der alte Stand (z. B. ein geschwärzter
|
||||
* Klarname) zurück. Idempotent; die erste Sperre bleibt maßgeblich.
|
||||
*/
|
||||
public function lockSync(string $reason): void
|
||||
{
|
||||
if ($this->isSyncLocked()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->forceFill([
|
||||
'sync_locked_at' => now(),
|
||||
'sync_lock_reason' => Str::limit($reason, 250),
|
||||
])->save();
|
||||
|
||||
app(ActivityLog::class)->record(
|
||||
ActivityType::SyncLock,
|
||||
sprintf('Re-Sync-Sperre gesetzt: %s', $reason),
|
||||
subject: $this,
|
||||
actorLabel: 'System',
|
||||
);
|
||||
}
|
||||
|
||||
public function isSyncLocked(): bool
|
||||
{
|
||||
return $this->sync_locked_at !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hinterlegte Pressekontaktadresse für das Meldeverfahren: erst der
|
||||
* PM-Kontakt, dann die Firmen-Adresse. Bewusst ohne PortalScope — die
|
||||
* Meldeseite läuft host-agnostisch auf allen Domains.
|
||||
*/
|
||||
public function pressContactEmail(): ?string
|
||||
{
|
||||
$contactEmail = $this->contacts()
|
||||
->withoutGlobalScopes()
|
||||
->whereNotNull('email')
|
||||
->where('email', '!=', '')
|
||||
->value('email');
|
||||
|
||||
if (is_string($contactEmail) && $contactEmail !== '') {
|
||||
return $contactEmail;
|
||||
}
|
||||
|
||||
$companyEmail = $this->company()->withoutGlobalScopes()->value('email');
|
||||
|
||||
return is_string($companyEmail) && $companyEmail !== '' ? $companyEmail : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sperrfrist (Embargo) in der Anwendungs-Zeitzone (Europe/Berlin).
|
||||
*/
|
||||
|
|
|
|||
73
app/Models/PressReleaseRedactionSnapshot.php
Normal file
73
app/Models/PressReleaseRedactionSnapshot.php
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\PressReleaseRedactionSnapshotFactory;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* Verschlüsselter Vorher-Snapshot einer Meldeverfahren-Mutation
|
||||
* (Anonymisierung/Depublizierung). Existiert nur für die Reversibilität
|
||||
* innerhalb der Löschfrist — Alt-Werte leben nie im Klartext in Logs
|
||||
* oder Payloads weiter. Wird nach purge_after durch snapshots:purge
|
||||
* gelöscht (config legal.snapshot_retention_days).
|
||||
*/
|
||||
class PressReleaseRedactionSnapshot extends Model
|
||||
{
|
||||
/** @use HasFactory<PressReleaseRedactionSnapshotFactory> */
|
||||
use HasFactory;
|
||||
|
||||
public const UPDATED_AT = null;
|
||||
|
||||
protected $fillable = [
|
||||
'legal_request_id',
|
||||
'press_release_id',
|
||||
'encrypted_before',
|
||||
'purge_after',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'encrypted_before' => 'encrypted:array',
|
||||
'purge_after' => 'date',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Snapshot mit Löschfrist ab heute (config legal.snapshot_retention_days).
|
||||
*
|
||||
* @param array<string, mixed> $before
|
||||
*/
|
||||
public static function capture(PressRelease $pressRelease, array $before, ?LegalRequest $legalRequest = null): self
|
||||
{
|
||||
return self::query()->create([
|
||||
'legal_request_id' => $legalRequest?->getKey(),
|
||||
'press_release_id' => $pressRelease->getKey(),
|
||||
'encrypted_before' => $before,
|
||||
'purge_after' => now()->addDays((int) config('legal.snapshot_retention_days'))->toDateString(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function legalRequest(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(LegalRequest::class);
|
||||
}
|
||||
|
||||
public function pressRelease(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PressRelease::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder<PressReleaseRedactionSnapshot> $query
|
||||
* @return Builder<PressReleaseRedactionSnapshot>
|
||||
*/
|
||||
public function scopeDueForPurge(Builder $query): Builder
|
||||
{
|
||||
return $query->whereDate('purge_after', '<', now()->toDateString());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue