Skip to content

Commit

Permalink
Merge branch '1.0-develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewpi committed Apr 11, 2024
2 parents 6a33c73 + f671046 commit 7f192dc
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
14 changes: 0 additions & 14 deletions app/Http/Controllers/Admin/BaseController.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,21 @@ public function __construct(private BackupManager $backupManager)
*/
public function __invoke(Request $request, string $backup): JsonResponse
{
// Get the node associated with the request.
/** @var \Pterodactyl\Models\Node $node */
$node = $request->attributes->get('node');

// Get the size query parameter.
$size = (int) $request->query('size');
if (empty($size)) {
throw new BadRequestHttpException('A non-empty "size" query parameter must be provided.');
}

/** @var \Pterodactyl\Models\Backup $backup */
$backup = Backup::query()->where('uuid', $backup)->firstOrFail();
$backup = Backup::query()
->where('node_id', $node->id)
->where('uuid', $backup)
->firstOrFail();

// Prevent backups that have already been completed from trying to
// be uploaded again.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@ public function __construct(private BackupManager $backupManager)
*/
public function index(ReportBackupCompleteRequest $request, string $backup): JsonResponse
{
/** @var \Pterodactyl\Models\Backup $model */
$model = Backup::query()->where('uuid', $backup)->firstOrFail();
// Get the node associated with the request.
/** @var \Pterodactyl\Models\Node $node */
$node = $request->attributes->get('node');

/** @var \Pterodactyl\Models\Backup $backup */
$backup = Backup::query()
->where('node_id', $node->id)
->where('uuid', $backup)
->firstOrFail();

if ($model->is_successful) {

Check failure on line 43 in app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php

View workflow job for this annotation

GitHub Actions / Static Analysis

Undefined variable: $model
throw new BadRequestHttpException('Cannot update the status of a backup that is already marked as completed.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function rules(): array
Assert::isInstanceOf($server, Server::class);

return [
'docker_image' => ['required', 'string', Rule::in(array_values($server->egg->docker_images))],
'docker_image' => ['required', 'string', 'max:191', 'regex:/^[\w#\.\/\- ]*\|*[\w\.\/\-:@ ]*$/', Rule::in(array_values($server->egg->docker_images))],
];
}
}
2 changes: 1 addition & 1 deletion app/Models/Egg.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class Egg extends Model
'file_denylist' => 'array|nullable',
'file_denylist.*' => 'string',
'docker_images' => 'required|array|min:1',
'docker_images.*' => 'required|string',
'docker_images.*' => ['required', 'string', 'max:191', 'regex:/^[\w#\.\/\- ]*\|*[\w\.\/\-:@ ]*$/'],
'startup' => 'required|nullable|string',
'config_from' => 'sometimes|bail|nullable|numeric|exists:eggs,id',
'config_stop' => 'required_without:config_from|nullable|string|max:191',
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class Server extends Model
'egg_id' => 'required|exists:eggs,id',
'startup' => 'nullable|string',
'skip_scripts' => 'sometimes|boolean',
'image' => 'required|string|max:191',
'image' => ['required', 'string', 'max:191', 'regex:/^[\w\.\/\-:@ ]*$/'],
'database_limit' => 'present|nullable|integer|min:0',
'allocation_limit' => 'sometimes|nullable|integer|min:0',
'backup_limit' => 'present|nullable|integer|min:0',
Expand Down

0 comments on commit 7f192dc

Please sign in to comment.