api(application): v2 backport
This commit is contained in:
parent
4cd0bee231
commit
67bf3e342e
172 changed files with 2922 additions and 1579 deletions
|
@ -4,7 +4,6 @@ namespace Pterodactyl\Services\Eggs;
|
|||
|
||||
use Illuminate\Support\Arr;
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Collection;
|
||||
use Pterodactyl\Exceptions\Service\InvalidFileUploadException;
|
||||
|
||||
|
@ -13,17 +12,10 @@ class EggParserService
|
|||
/**
|
||||
* Takes an uploaded file and parses out the egg configuration from within.
|
||||
*
|
||||
* @throws \JsonException
|
||||
* @throws \Pterodactyl\Exceptions\Service\InvalidFileUploadException
|
||||
*/
|
||||
public function handle(UploadedFile $file): array
|
||||
public function handle(array $parsed): array
|
||||
{
|
||||
if ($file->getError() !== UPLOAD_ERR_OK || !$file->isFile()) {
|
||||
throw new InvalidFileUploadException('The selected file is not valid and cannot be imported.');
|
||||
}
|
||||
|
||||
/** @var array $parsed */
|
||||
$parsed = json_decode($file->openFile()->fread($file->getSize()), true, 512, JSON_THROW_ON_ERROR);
|
||||
if (!in_array(Arr::get($parsed, 'meta.version') ?? '', ['PTDL_v1', 'PTDL_v2'])) {
|
||||
throw new InvalidFileUploadException('The JSON file provided is not in a format that can be recognized.');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue