- Event-Medien tragen Typ (image/video/audio), Dauer und Notiz; Videos bekommen ein Poster, Audio wird per ffmpeg nach AAC (audio/mp4) gewandelt, Originale werden mit Range-Unterstützung gestreamt. - Upload nimmt eine Notiz (caption) direkt mit, PATCH ändert sie später. - Neue Event-Felder: Zeitraum (end_date), Kategorie, Personen, Meilenstein. Regeln zentral in EventFields, damit CRUD und Sync gleich prüfen. - Titel darf leer sein: ein Event entsteht mit dem ersten Eintrag. - Artisan-Befehl media:transcode-voice-notes wandelt alte WebM/Ogg-Notizen, die Safari nicht abspielen kann. - Login-Throttling, Settings-Validierung, Sync-Fehlercodes ohne Rohtext. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
77 lines
2 KiB
PHP
77 lines
2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use App\Support\SettingsSchema;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Validator;
|
|
|
|
class UpdateSettingsRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return SettingsSchema::rules();
|
|
}
|
|
|
|
/**
|
|
* Reject keys the schema does not know about instead of persisting them.
|
|
*
|
|
* @return array<int, callable>
|
|
*/
|
|
public function after(): array
|
|
{
|
|
return [
|
|
function (Validator $validator): void {
|
|
$this->rejectUnknownKeys(
|
|
$validator,
|
|
'settings',
|
|
(array) $this->input('settings', []),
|
|
SettingsSchema::allowedKeys(),
|
|
);
|
|
|
|
$floatingLines = $this->input('settings.floatingLines');
|
|
|
|
if (is_array($floatingLines)) {
|
|
$this->rejectUnknownKeys(
|
|
$validator,
|
|
'settings.floatingLines',
|
|
$floatingLines,
|
|
SettingsSchema::allowedFloatingLineKeys(),
|
|
);
|
|
}
|
|
},
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $given
|
|
* @param array<int, string> $allowed
|
|
*/
|
|
private function rejectUnknownKeys(
|
|
Validator $validator,
|
|
string $attribute,
|
|
array $given,
|
|
array $allowed,
|
|
): void {
|
|
$unknown = array_diff(array_keys($given), $allowed);
|
|
|
|
if ($unknown === []) {
|
|
return;
|
|
}
|
|
|
|
$validator->errors()->add(
|
|
$attribute,
|
|
'Unknown settings keys: '.implode(', ', array_map('strval', $unknown)).'.',
|
|
);
|
|
}
|
|
}
|