Skip to content

Commit 0a2c89e

Browse files
committed
Reeformat with new rules post merge
1 parent 663143d commit 0a2c89e

File tree

14 files changed

+104
-159
lines changed

14 files changed

+104
-159
lines changed

app/Exceptions/Http/Connection/DaemonConnectionException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ public function __construct(GuzzleException $previous, bool $useStatusCode = tru
4848

4949
// Attempt to pull the actual error message off the response and return that if it is not
5050
// a 500 level error.
51-
if ($this->statusCode < 500 && ! is_null($response)) {
51+
if ($this->statusCode < 500 && !is_null($response)) {
5252
$body = json_decode($response->getBody()->__toString(), true);
53-
$message = sprintf("An error occurred on the remote host: %s. (request id: %s)", $body['error'] ?? $message, $this->requestId ?? '<nil>');
53+
$message = sprintf('An error occurred on the remote host: %s. (request id: %s)', $body['error'] ?? $message, $this->requestId ?? '<nil>');
5454
}
5555

5656
$level = $this->statusCode >= 500 && $this->statusCode !== 504

app/Http/Controllers/Admin/Servers/ServerViewController.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,7 @@ public function mounts(Request $request, Server $server)
185185
public function manage(Request $request, Server $server)
186186
{
187187
if ($server->status === Server::STATUS_INSTALL_FAILED) {
188-
throw new DisplayException(
189-
'This server is in a failed install state and cannot be recovered. Please delete and re-create the server.'
190-
);
188+
throw new DisplayException('This server is in a failed install state and cannot be recovered. Please delete and re-create the server.');
191189
}
192190

193191
// Check if the panel doesn't have at least 2 nodes configured.

app/Http/Controllers/Api/Client/Servers/BackupController.php

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
use Pterodactyl\Services\Backups\DeleteBackupService;
1313
use Pterodactyl\Services\Backups\DownloadLinkService;
1414
use Pterodactyl\Services\Backups\InitiateBackupService;
15-
use Pterodactyl\Transformers\Api\Client\BackupTransformer;
1615
use Pterodactyl\Repositories\Wings\DaemonBackupRepository;
16+
use Pterodactyl\Transformers\Api\Client\BackupTransformer;
1717
use Pterodactyl\Http\Controllers\Api\Client\ClientApiController;
1818
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
1919
use Pterodactyl\Http\Requests\Api\Client\Servers\Backups\StoreBackupRequest;
@@ -42,11 +42,6 @@ class BackupController extends ClientApiController
4242

4343
/**
4444
* BackupController constructor.
45-
*
46-
* @param \Pterodactyl\Repositories\Wings\DaemonBackupRepository $repository
47-
* @param \Pterodactyl\Services\Backups\DeleteBackupService $deleteBackupService
48-
* @param \Pterodactyl\Services\Backups\InitiateBackupService $initiateBackupService
49-
* @param \Pterodactyl\Services\Backups\DownloadLinkService $downloadLinkService
5045
*/
5146
public function __construct(
5247
DaemonBackupRepository $repository,
@@ -66,14 +61,12 @@ public function __construct(
6661
* Returns all of the backups for a given server instance in a paginated
6762
* result set.
6863
*
69-
* @param \Illuminate\Http\Request $request
70-
* @param \Pterodactyl\Models\Server $server
7164
* @return array
7265
*/
7366
public function index(Request $request, Server $server)
7467
{
75-
if (! $request->user()->can(Permission::ACTION_BACKUP_READ, $server)) {
76-
throw new UnauthorizedException;
68+
if (!$request->user()->can(Permission::ACTION_BACKUP_READ, $server)) {
69+
throw new UnauthorizedException();
7770
}
7871

7972
$limit = min($request->query('per_page') ?? 20, 50);
@@ -113,15 +106,12 @@ public function store(StoreBackupRequest $request, Server $server)
113106
/**
114107
* Returns information about a single backup.
115108
*
116-
* @param \Illuminate\Http\Request $request
117-
* @param \Pterodactyl\Models\Server $server
118-
* @param \Pterodactyl\Models\Backup $backup
119109
* @return array
120110
*/
121111
public function view(Request $request, Server $server, Backup $backup)
122112
{
123-
if (! $request->user()->can(Permission::ACTION_BACKUP_READ, $server)) {
124-
throw new UnauthorizedException;
113+
if (!$request->user()->can(Permission::ACTION_BACKUP_READ, $server)) {
114+
throw new UnauthorizedException();
125115
}
126116

127117
return $this->fractal->item($backup)
@@ -133,17 +123,14 @@ public function view(Request $request, Server $server, Backup $backup)
133123
* Deletes a backup from the panel as well as the remote source where it is currently
134124
* being stored.
135125
*
136-
* @param \Illuminate\Http\Request $request
137-
* @param \Pterodactyl\Models\Server $server
138-
* @param \Pterodactyl\Models\Backup $backup
139126
* @return \Illuminate\Http\JsonResponse
140127
*
141128
* @throws \Throwable
142129
*/
143130
public function delete(Request $request, Server $server, Backup $backup)
144131
{
145-
if (! $request->user()->can(Permission::ACTION_BACKUP_DELETE, $server)) {
146-
throw new UnauthorizedException;
132+
if (!$request->user()->can(Permission::ACTION_BACKUP_DELETE, $server)) {
133+
throw new UnauthorizedException();
147134
}
148135

149136
$server->audit(AuditLog::SERVER__BACKUP_DELETED, function (AuditLog $audit) use ($backup) {
@@ -160,15 +147,12 @@ public function delete(Request $request, Server $server, Backup $backup)
160147
* will be streamed back through the Panel. For AWS S3 files, a signed URL will be generated
161148
* which the user is redirected to.
162149
*
163-
* @param \Illuminate\Http\Request $request
164-
* @param \Pterodactyl\Models\Server $server
165-
* @param \Pterodactyl\Models\Backup $backup
166150
* @return \Illuminate\Http\JsonResponse
167151
*/
168152
public function download(Request $request, Server $server, Backup $backup)
169153
{
170-
if (! $request->user()->can(Permission::ACTION_BACKUP_DOWNLOAD, $server)) {
171-
throw new UnauthorizedException;
154+
if (!$request->user()->can(Permission::ACTION_BACKUP_DOWNLOAD, $server)) {
155+
throw new UnauthorizedException();
172156
}
173157

174158
switch ($backup->disk) {
@@ -179,7 +163,7 @@ public function download(Request $request, Server $server, Backup $backup)
179163
'attributes' => ['url' => ''],
180164
]);
181165
default:
182-
throw new BadRequestHttpException;
166+
throw new BadRequestHttpException();
183167
}
184168
}
185169

@@ -192,22 +176,19 @@ public function download(Request $request, Server $server, Backup $backup)
192176
* files that currently exist on the server will be deleted before restoring.
193177
* Otherwise the archive will simply be unpacked over the existing files.
194178
*
195-
* @param \Illuminate\Http\Request $request
196-
* @param \Pterodactyl\Models\Server $server
197-
* @param \Pterodactyl\Models\Backup $backup
198179
* @return \Illuminate\Http\JsonResponse
199180
*
200181
* @throws \Throwable
201182
*/
202183
public function restore(Request $request, Server $server, Backup $backup)
203184
{
204-
if (! $request->user()->can(Permission::ACTION_BACKUP_RESTORE, $server)) {
205-
throw new UnauthorizedException;
185+
if (!$request->user()->can(Permission::ACTION_BACKUP_RESTORE, $server)) {
186+
throw new UnauthorizedException();
206187
}
207188

208189
// Cannot restore a backup unless a server is fully installed and not currently
209190
// processing a different backup restoration request.
210-
if (! is_null($server->status)) {
191+
if (!is_null($server->status)) {
211192
throw new BadRequestHttpException('This server is not currently in a state that allows for a backup to be restored.');
212193
}
213194

app/Http/Controllers/Api/Client/Servers/FileController.php

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,13 @@ public function directory(ListFilesRequest $request, Server $server): array
7575
/**
7676
* Return the contents of a specified file for the user.
7777
*
78-
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\GetFileContentsRequest $request
79-
* @param \Pterodactyl\Models\Server $server
80-
* @return \Illuminate\Http\Response
81-
*
8278
* @throws \Throwable
8379
*/
8480
public function contents(GetFileContentsRequest $request, Server $server): Response
8581
{
8682
$response = $this->fileRepository->setServer($server)->getContent(
87-
$request->get('file'), config('pterodactyl.files.max_edit_size')
83+
$request->get('file'),
84+
config('pterodactyl.files.max_edit_size')
8885
);
8986

9087
return new Response($response, Response::HTTP_OK, ['Content-Type' => 'text/plain']);
@@ -146,10 +143,6 @@ public function write(WriteFileContentRequest $request, Server $server): JsonRes
146143
/**
147144
* Creates a new folder on the server.
148145
*
149-
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\CreateFolderRequest $request
150-
* @param \Pterodactyl\Models\Server $server
151-
* @return \Illuminate\Http\JsonResponse
152-
*
153146
* @throws \Throwable
154147
*/
155148
public function create(CreateFolderRequest $request, Server $server): JsonResponse
@@ -169,10 +162,6 @@ public function create(CreateFolderRequest $request, Server $server): JsonRespon
169162
/**
170163
* Renames a file on the remote machine.
171164
*
172-
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\RenameFileRequest $request
173-
* @param \Pterodactyl\Models\Server $server
174-
* @return \Illuminate\Http\JsonResponse
175-
*
176165
* @throws \Throwable
177166
*/
178167
public function rename(RenameFileRequest $request, Server $server): JsonResponse
@@ -220,7 +209,8 @@ public function compress(CompressFilesRequest $request, Server $server): array
220209

221210
return $this->fileRepository->setServer($server)
222211
->compressFiles(
223-
$request->input('root'), $request->input('files')
212+
$request->input('root'),
213+
$request->input('files')
224214
);
225215
});
226216

@@ -259,7 +249,8 @@ public function delete(DeleteFileRequest $request, Server $server): JsonResponse
259249

260250
$this->fileRepository->setServer($server)
261251
->deleteFiles(
262-
$request->input('root'), $request->input('files')
252+
$request->input('root'),
253+
$request->input('files')
263254
);
264255
});
265256

app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ public function index(ReportBackupCompleteRequest $request, string $backup)
8888
* The only thing the successful field does is update the entry value for the audit logs
8989
* table tracking for this restoration.
9090
*
91-
* @param \Illuminate\Http\Request $request
92-
* @param string $backup
9391
* @return \Illuminate\Http\JsonResponse
9492
*
9593
* @throws \Throwable
@@ -104,7 +102,7 @@ public function restore(Request $request, string $backup)
104102

105103
// Just create a new audit entry for this event and update the server state
106104
// so that power actions, file management, and backups can resume as normal.
107-
$model->server->audit($action, function (AuditLog $audit, Server $server) use ($backup, $request) {
105+
$model->server->audit($action, function (AuditLog $audit, Server $server) use ($backup) {
108106
$audit->is_system = true;
109107
$audit->metadata = ['backup_uuid' => $backup];
110108
$server->update(['status' => null]);

app/Http/Middleware/Admin/Servers/ServerInstalled.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ public function handle(Request $request, Closure $next)
2525
throw new NotFoundHttpException('No server resource was located in the request parameters.');
2626
}
2727

28-
if (! $server->isInstalled()) {
29-
throw new HttpException(
30-
Response::HTTP_FORBIDDEN, 'Access to this resource is not allowed due to the current installation state.'
31-
);
28+
if (!$server->isInstalled()) {
29+
throw new HttpException(Response::HTTP_FORBIDDEN, 'Access to this resource is not allowed due to the current installation state.');
3230
}
3331

3432
return $next($request);

app/Http/Middleware/Server/AccessingValidServer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function handle(Request $request, Closure $next)
6767

6868
// Servers can have install statuses other than 1 or 0, so don't check
6969
// for a bool-type operator here.
70-
if (! $server->isInstalled()) {
70+
if (!$server->isInstalled()) {
7171
if ($isApiRequest) {
7272
throw new ConflictHttpException('Server is still completing the installation process.');
7373
}

app/Models/AuditLog.php

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,37 @@
77
use Illuminate\Container\Container;
88

99
/**
10-
* @property int $id
11-
* @property string $uuid
12-
* @property bool $is_system
13-
* @property int|null $user_id
14-
* @property int|null $server_id
15-
* @property string $action
16-
* @property string|null $subaction
17-
* @property array $device
18-
* @property array $metadata
19-
* @property \Carbon\CarbonImmutable $created_at
20-
*
21-
* @property \Pterodactyl\Models\User|null $user
10+
* @property int $id
11+
* @property string $uuid
12+
* @property bool $is_system
13+
* @property int|null $user_id
14+
* @property int|null $server_id
15+
* @property string $action
16+
* @property string|null $subaction
17+
* @property array $device
18+
* @property array $metadata
19+
* @property \Carbon\CarbonImmutable $created_at
20+
* @property \Pterodactyl\Models\User|null $user
2221
* @property \Pterodactyl\Models\Server|null $server
2322
*/
2423
class AuditLog extends Model
2524
{
26-
const UPDATED_AT = null;
25+
public const UPDATED_AT = null;
2726

28-
const SERVER__FILESYSTEM_DOWNLOAD = 'server:filesystem.download';
29-
const SERVER__FILESYSTEM_WRITE = 'server:filesystem.write';
30-
const SERVER__FILESYSTEM_DELETE = 'server:filesystem.delete';
31-
const SERVER__FILESYSTEM_RENAME = 'server:filesystem.rename';
32-
const SERVER__FILESYSTEM_COMPRESS = 'server:filesystem.compress';
33-
const SERVER__FILESYSTEM_DECOMPRESS = 'server:filesystem.decompress';
34-
const SERVER__FILESYSTEM_PULL = 'server:filesystem.pull';
35-
const SERVER__BACKUP_STARTED = 'server:backup.started';
36-
const SERVER__BACKUP_FAILED = 'server:backup.failed';
37-
const SERVER__BACKUP_COMPELTED = 'server:backup.completed';
38-
const SERVER__BACKUP_DELETED = 'server:backup.deleted';
39-
const SERVER__BACKUP_RESTORE_STARTED = 'server:backup.restore.started';
40-
const SERVER__BACKUP_RESTORE_COMPLETED = 'server:backup.restore.completed';
41-
const SERVER__BACKUP_RESTORE_FAILED = 'server:backup.restore.failed';
27+
public const SERVER__FILESYSTEM_DOWNLOAD = 'server:filesystem.download';
28+
public const SERVER__FILESYSTEM_WRITE = 'server:filesystem.write';
29+
public const SERVER__FILESYSTEM_DELETE = 'server:filesystem.delete';
30+
public const SERVER__FILESYSTEM_RENAME = 'server:filesystem.rename';
31+
public const SERVER__FILESYSTEM_COMPRESS = 'server:filesystem.compress';
32+
public const SERVER__FILESYSTEM_DECOMPRESS = 'server:filesystem.decompress';
33+
public const SERVER__FILESYSTEM_PULL = 'server:filesystem.pull';
34+
public const SERVER__BACKUP_STARTED = 'server:backup.started';
35+
public const SERVER__BACKUP_FAILED = 'server:backup.failed';
36+
public const SERVER__BACKUP_COMPELTED = 'server:backup.completed';
37+
public const SERVER__BACKUP_DELETED = 'server:backup.deleted';
38+
public const SERVER__BACKUP_RESTORE_STARTED = 'server:backup.restore.started';
39+
public const SERVER__BACKUP_RESTORE_COMPLETED = 'server:backup.restore.completed';
40+
public const SERVER__BACKUP_RESTORE_FAILED = 'server:backup.restore.failed';
4241

4342
/**
4443
* @var string[]
@@ -100,16 +99,13 @@ public function server()
10099
* currently authenticated user if available. This model is not saved at this point, so
101100
* you can always make modifications to it as needed before saving.
102101
*
103-
* @param string $action
104-
* @param array $metadata
105-
* @param bool $isSystem
106102
* @return $this
107103
*/
108104
public static function factory(string $action, array $metadata, bool $isSystem = false)
109105
{
110106
/** @var \Illuminate\Http\Request $request */
111107
$request = Container::getInstance()->make('request');
112-
if ($isSystem || ! $request instanceof Request) {
108+
if ($isSystem || !$request instanceof Request) {
113109
$request = null;
114110
}
115111

app/Models/Permission.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class Permission extends Model
157157
'read' => 'Allows a user to view all backups that exist for this server.',
158158
'delete' => 'Allows a user to remove backups from the system.',
159159
'download' => 'Allows a user to download a backup for the server. Danger: this allows a user to access all files for the server in the backup.',
160-
'restore' => 'Allows a user to restore a backup for the server. Danger: this allows the user to delete all of the server files in the process.'
160+
'restore' => 'Allows a user to restore a backup for the server. Danger: this allows the user to delete all of the server files in the process.',
161161
],
162162
],
163163

0 commit comments

Comments
 (0)