Decision-Update Abschnitt 12 (E15, S24): Sichtung auf offensichtliche Probleme, keine Rechteprüfung, öffentlich weiterhin „automatisierte Prüfung". - ImagePrecheckManager mit openai- und deterministic-Treiber (Muster der Text-Prüfstrecke), Bild auf 1024 px, Metadaten gestrippt, JPEG als Data-URI, Antwortschema 12.4; Fehler → Ausgang `error`, durchlassen mit Vermerk. - Auswertung 12.3: reject (Stock-Wasserzeichen, Nacktheit/Gewalt, Dokument ab 0,85), queue (Screenshot, fremdes Logo, Kennzeichen ab 0,6 sowie Ablehnungskategorien 0,6–0,85), hint (Personen, „wirkt KI" nur bei „ohne KI", technischer Mangel). Stufe 1 wertet nur das Wasserzeichen; die KI setzt nie die Kennzeichnung (E9). Herabstufung per Config (12.8). - Uploader: Check vor jedem Schreiben, Ablehnung speichert nichts und landet als ki_audits `image_precheck` an der PM; Hash-Bindung zwischen Vorprüfung im Formular und Speichern; Spalten precheck*, Snapshot `precheck_snapshot` im Bestätigungsprotokoll, Archiv-Payload erweitert. - Queue: Bild zurückgehalten (withheld_at), Meldung läuft weiter; Admin entscheidet mit Vermerk (Freigabe/Ablehnung → ki_audits `image_precheck_review`); Ansicht „Bild-Sichtung" in der PM-Liste, Sichtungsblock auf der PM-Seite, Systemstatus-Zähler. - Formular v2: Ablehnungsgrund unter dem Dateifeld, Hinweise nach der Dateiauswahl, „wird kurz gesichtet" an der Karte; API 422 mit Grund, Warnung `image_under_review`. - Config images.precheck (IMAGE_PRECHECK aus, STAGE 1); 17 Tests. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
130 lines
3.4 KiB
PHP
130 lines
3.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\ConfirmationChannel;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|
|
|
/**
|
|
* Protokollierte Rechtebestätigung zu einem Bild (Bildkennzeichnung A.2).
|
|
*
|
|
* Insert-only: `ImageRightsConfirmationObserver` wirft bei Update und
|
|
* Delete. Die einzige zulässige Löschung ist die Sofortlöschung eines nie
|
|
* veröffentlichten Uploads (Decision-Update E4) über purgeForUnpublished().
|
|
*
|
|
* `user_id` ist der Kontoinhaber und damit der Vertragspartner (E1);
|
|
* `company_id` ist nur die Zuordnung zum Firmenprofil. `text_snapshot` hält
|
|
* den gerenderten Wortlaut mit aufgelöster AGB-Fassung fest, damit die
|
|
* Bestätigung auch dann rekonstruierbar bleibt, wenn `legal_texts` und
|
|
* `legal_documents` weiterwachsen.
|
|
*/
|
|
class ImageRightsConfirmation extends Model
|
|
{
|
|
public const UPDATED_AT = null;
|
|
|
|
/**
|
|
* Vom Observer geprüfter Freischein für die Sofortlöschung nie
|
|
* veröffentlichter Uploads (E.3). Nie von außen setzen.
|
|
*/
|
|
public bool $purgingUnpublished = false;
|
|
|
|
protected $fillable = [
|
|
'subject_type',
|
|
'subject_id',
|
|
'press_release_id',
|
|
'company_id',
|
|
'user_id',
|
|
'personal_access_token_id',
|
|
'channel',
|
|
'legal_text_id',
|
|
'legal_text_key',
|
|
'text_snapshot',
|
|
'agb_version',
|
|
'locale',
|
|
'file_sha256',
|
|
'declaration_snapshot',
|
|
'precheck_snapshot',
|
|
'ip_hmac',
|
|
'user_agent',
|
|
'confirmed_at',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'channel' => ConfirmationChannel::class,
|
|
'declaration_snapshot' => 'array',
|
|
'precheck_snapshot' => 'array',
|
|
'confirmed_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Pseudonymisierte IP-Ableitung: HMAC mit eigenem Schlüssel und
|
|
* Versionspräfix (Decision-Update 3.7). Kein reiner Hash — ohne den
|
|
* Schlüssel lässt sich keine Adresse zuordnen.
|
|
*/
|
|
public static function hashIp(?string $ip): ?string
|
|
{
|
|
if (blank($ip)) {
|
|
return null;
|
|
}
|
|
|
|
$key = (string) config('images.confirmation_ip_key');
|
|
$version = (string) config('images.confirmation_ip_hash_version', 'v1');
|
|
|
|
return $version.':'.hash_hmac('sha256', $ip, $key);
|
|
}
|
|
|
|
/**
|
|
* Sofortlöschung eines nie veröffentlichten Uploads (E.3). Nur hier
|
|
* darf eine Bestätigung verschwinden — der Observer prüft das Flag.
|
|
*/
|
|
public function purgeForUnpublished(): void
|
|
{
|
|
$this->purgingUnpublished = true;
|
|
$this->delete();
|
|
}
|
|
|
|
/**
|
|
* @return MorphTo<Model, $this>
|
|
*/
|
|
public function subject(): MorphTo
|
|
{
|
|
return $this->morphTo();
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<PressRelease, $this>
|
|
*/
|
|
public function pressRelease(): BelongsTo
|
|
{
|
|
return $this->belongsTo(PressRelease::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<Company, $this>
|
|
*/
|
|
public function company(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Company::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<User, $this>
|
|
*/
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<LegalText, $this>
|
|
*/
|
|
public function legalText(): BelongsTo
|
|
{
|
|
return $this->belongsTo(LegalText::class);
|
|
}
|
|
}
|