Wire admin studio SSR and search infrastructure
This commit is contained in:
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Http\Requests\Uploads;
|
||||
|
||||
use App\Models\Artwork;
|
||||
use App\Models\UploadBatchItem;
|
||||
use App\Repositories\Uploads\UploadSessionRepository;
|
||||
use App\Services\Uploads\UploadTokenService;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
@@ -13,6 +14,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
final class UploadFinishRequest extends FormRequest
|
||||
{
|
||||
private ?Artwork $artwork = null;
|
||||
private ?UploadBatchItem $batchItem = null;
|
||||
|
||||
public function authorize(): bool
|
||||
{
|
||||
@@ -97,6 +99,22 @@ final class UploadFinishRequest extends FormRequest
|
||||
$this->denyAsNotFound();
|
||||
}
|
||||
|
||||
$batchItemId = (int) $this->input('batch_item_id');
|
||||
if ($batchItemId > 0) {
|
||||
$batchItem = UploadBatchItem::query()->find($batchItemId);
|
||||
if (! $batchItem || (int) $batchItem->user_id !== (int) $user->id) {
|
||||
$this->logUnauthorized('batch_item_not_owned_or_missing');
|
||||
$this->denyAsNotFound();
|
||||
}
|
||||
|
||||
if ((int) ($batchItem->artwork_id ?? 0) > 0 && (int) $batchItem->artwork_id !== $artworkId) {
|
||||
$this->logUnauthorized('batch_item_artwork_mismatch');
|
||||
$this->denyAsNotFound();
|
||||
}
|
||||
|
||||
$this->batchItem = $batchItem;
|
||||
}
|
||||
|
||||
$this->artwork = $artwork;
|
||||
|
||||
return true;
|
||||
@@ -109,6 +127,7 @@ final class UploadFinishRequest extends FormRequest
|
||||
'artwork_id' => 'required|integer',
|
||||
'upload_token' => 'nullable|string|min:40|max:200',
|
||||
'file_name' => 'nullable|string|max:255',
|
||||
'batch_item_id' => 'nullable|integer|min:1',
|
||||
'archive_session_id' => 'nullable|uuid|different:session_id',
|
||||
'archive_file_name' => 'nullable|string|max:255',
|
||||
'additional_screenshot_sessions' => 'nullable|array|max:4',
|
||||
@@ -126,6 +145,11 @@ final class UploadFinishRequest extends FormRequest
|
||||
return $this->artwork;
|
||||
}
|
||||
|
||||
public function batchItem(): ?UploadBatchItem
|
||||
{
|
||||
return $this->batchItem;
|
||||
}
|
||||
|
||||
private function denyAsNotFound(): void
|
||||
{
|
||||
throw new NotFoundHttpException();
|
||||
|
||||
Reference in New Issue
Block a user