api: Bildupload v1 unter Formular v2 (Pflichtfelder, Kennung des Wortlauts, Bestätigung mit Token), Legacy-Bildupload abgeschaltet, API-Doku (Bildkennzeichnung Block C)
- StorePressReleaseImageRequest: copyright, rights_confirmed, confirm_text_version Pflicht; 422 mit aktueller Kennung; 16 MiB
- PressReleaseImageController über den gemeinsamen Uploader, Löschen über den Remover; Resource mit Portalkennzeichnung, Kundenangabe, Herkunft, Bestätigung und warnings[]
- POST /service/pressreleases/{id}/images antwortet 410 mit Hinweis auf v1 (E-B4)
- API-Seite und Sprachdateien: Felder und Rechtehinweis mit aktiver Textkennung; Paritätsdokument ergänzt
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
40953d6c65
commit
65ac72ce05
9 changed files with 411 additions and 30 deletions
|
|
@ -3,9 +3,11 @@
|
|||
namespace App\Http\Requests\Api\V1;
|
||||
|
||||
use App\Enums\AiImageDeclaration;
|
||||
use App\Services\Image\ImageRightsTextRenderer;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
class StorePressReleaseImageRequest extends FormRequest
|
||||
{
|
||||
|
|
@ -20,27 +22,76 @@ class StorePressReleaseImageRequest extends FormRequest
|
|||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* KI-Kennzeichnung je Bild (Art. 50 KI-VO) ist im v1-Vertrag Pflicht;
|
||||
* Legacy-/service-Clients kennen das Feld nicht — dort greift der
|
||||
* Kompatibilitäts-Default „original" (Entscheidung 10.07.2026).
|
||||
* KI-Kennzeichnung je Bild (Art. 50 KI-VO) ist im v1-Vertrag Pflicht.
|
||||
* Mit Formular v2 (Bildkennzeichnung Block C, Decision-Update S4) kommen
|
||||
* Bildnachweis, Rechtebestätigung und die Kennung des bestätigten
|
||||
* Wortlauts als Pflichtfelder dazu; Lizenz- und Quellenlink,
|
||||
* Fokuspunkt und Letterbox bleiben optional.
|
||||
*
|
||||
* @return array<string, ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$isLegacyServiceCall = str_starts_with((string) $this->route()?->getName(), 'legacy-service.');
|
||||
$rightsV2 = (bool) config('images.rights_v2');
|
||||
$maxKilobytes = $rightsV2 ? (int) ((int) config('images.max_bytes') / 1024) : 8192;
|
||||
|
||||
return [
|
||||
'image' => ['required', 'image', 'mimes:jpg,jpeg,png,webp', 'max:8192'],
|
||||
'ai_declaration' => [
|
||||
Rule::requiredIf(! $isLegacyServiceCall),
|
||||
'nullable',
|
||||
Rule::enum(AiImageDeclaration::class),
|
||||
],
|
||||
$rules = [
|
||||
'image' => ['required', 'image', 'mimes:jpg,jpeg,png,webp', 'max:'.$maxKilobytes],
|
||||
'ai_declaration' => ['required', Rule::enum(AiImageDeclaration::class)],
|
||||
'title' => ['nullable', 'string', 'max:120'],
|
||||
'description' => ['nullable', 'string', 'max:500'],
|
||||
'copyright' => ['nullable', 'string', 'max:255'],
|
||||
'copyright' => [$rightsV2 ? 'required' : 'nullable', 'string', 'max:255'],
|
||||
'is_preview' => ['nullable', 'boolean'],
|
||||
];
|
||||
|
||||
if ($rightsV2) {
|
||||
$rules += [
|
||||
'rights_confirmed' => ['required', 'accepted'],
|
||||
'confirm_text_version' => ['required', 'string', 'max:40'],
|
||||
'license_url' => ['nullable', 'url:http,https', 'max:2048'],
|
||||
'source_url' => ['nullable', 'url:http,https', 'max:2048'],
|
||||
'focus_x' => ['nullable', 'integer', 'between:0,100'],
|
||||
'focus_y' => ['nullable', 'integer', 'between:0,100'],
|
||||
'no_crop' => ['nullable', 'boolean'],
|
||||
];
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Kennung muss die heute aktive Fassung sein; sonst 422 mit Hinweis
|
||||
* auf die aktuelle Kennung (Decision-Update 7.1: „sonst 422 mit Hinweis").
|
||||
*/
|
||||
public function after(): array
|
||||
{
|
||||
return [
|
||||
function (Validator $validator): void {
|
||||
if (! config('images.rights_v2') || $validator->errors()->has('confirm_text_version')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$current = app(ImageRightsTextRenderer::class)->current();
|
||||
$given = (string) $this->input('confirm_text_version');
|
||||
|
||||
if ($current === null || $given !== $current->key) {
|
||||
$validator->errors()->add(
|
||||
'confirm_text_version',
|
||||
sprintf('The confirmation text version is not current. Current version: %s.', $current?->key ?? 'none'),
|
||||
);
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'rights_confirmed.accepted' => 'The rights confirmation is required (rights_confirmed must be true).',
|
||||
'copyright.required' => 'The image credit (copyright) is required.',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue