Skip to content

Commit

Permalink
Merge pull request #65 from Ashu11-A/develop
Browse files Browse the repository at this point in the history
Revertendo...
  • Loading branch information
Ashu11-A authored Mar 4, 2023
2 parents 09cd4b0 + 6b9cbf8 commit 5b13b9d
Show file tree
Hide file tree
Showing 66 changed files with 11,856 additions and 806 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [8.1, 8.2]
php: [8.0, 8.1]
database: ["mariadb:10.2", "mysql:8"]
services:
database:
Expand Down
7 changes: 2 additions & 5 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Kernel extends ConsoleKernel
/**
* Register the commands for the application.
*/
protected function commands(): void
protected function commands()
{
$this->load(__DIR__ . '/Commands');
}
Expand All @@ -26,11 +26,8 @@ protected function commands(): void
/**
* Define the application's command schedule.
*/
protected function schedule(Schedule $schedule): void
protected function schedule(Schedule $schedule)
{
// https://laravel.com/docs/10.x/upgrade#redis-cache-tags
$schedule->command('cache:prune-stale-tags')->hourly();

// Execute scheduled commands for servers every minute, as if there was a normal cron running.
$schedule->command(ProcessRunnableCommand::class)->everyMinute()->withoutOverlapping();
$schedule->command(CleanServiceBackupFilesCommand::class)->daily();
Expand Down
2 changes: 1 addition & 1 deletion app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class Handler extends ExceptionHandler
*
* @noinspection PhpUnusedLocalVariableInspection
*/
public function register(): void
public function register()
{
if (config('app.exceptions.report_all', false)) {
$this->dontReport = [];
Expand Down
7 changes: 5 additions & 2 deletions app/Http/Controllers/Api/Client/Servers/BackupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Pterodactyl\Http\Controllers\Api\Client\ClientApiController;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Pterodactyl\Http\Requests\Api\Client\Servers\Backups\StoreBackupRequest;
use Pterodactyl\Http\Requests\Api\Client\Servers\Backups\RestoreBackupRequest;

class BackupController extends ClientApiController
{
Expand Down Expand Up @@ -189,8 +188,12 @@ public function download(Request $request, Server $server, Backup $backup): Json
*
* @throws \Throwable
*/
public function restore(RestoreBackupRequest $request, Server $server, Backup $backup): JsonResponse
public function restore(Request $request, Server $server, Backup $backup): JsonResponse
{
if (!$request->user()->can(Permission::ACTION_BACKUP_RESTORE, $server)) {
throw new AuthorizationException();
}

// Cannot restore a backup unless a server is fully installed and not currently
// processing a different backup restoration request.
if (!is_null($server->status)) {
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Kernel extends HttpKernel
/**
* The application's route middleware.
*/
protected $middlewareAliases = [
protected $routeMiddleware = [
'auth' => Authenticate::class,
'auth.basic' => AuthenticateWithBasicAuth::class,
'auth.session' => AuthenticateSession::class,
Expand Down

This file was deleted.

13 changes: 6 additions & 7 deletions app/Models/ApiKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* @property array|null $allowed_ips
* @property string|null $memo
* @property \Illuminate\Support\Carbon|null $last_used_at
* @property \Illuminate\Support\Carbon|null $expires_at
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property int $r_servers
Expand Down Expand Up @@ -98,10 +97,6 @@ class ApiKey extends Model
protected $casts = [
'allowed_ips' => 'array',
'user_id' => 'int',
'last_used_at' => 'datetime',
'expires_at' => 'datetime',
self::CREATED_AT => 'datetime',
self::UPDATED_AT => 'datetime',
'r_' . AdminAcl::RESOURCE_USERS => 'int',
'r_' . AdminAcl::RESOURCE_ALLOCATIONS => 'int',
'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS => 'int',
Expand All @@ -122,7 +117,6 @@ class ApiKey extends Model
'allowed_ips',
'memo',
'last_used_at',
'expires_at',
];

/**
Expand All @@ -143,7 +137,6 @@ class ApiKey extends Model
'allowed_ips' => 'nullable|array',
'allowed_ips.*' => 'string',
'last_used_at' => 'nullable|date',
'expires_at' => 'nullable|date',
'r_' . AdminAcl::RESOURCE_USERS => 'integer|min:0|max:3',
'r_' . AdminAcl::RESOURCE_ALLOCATIONS => 'integer|min:0|max:3',
'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS => 'integer|min:0|max:3',
Expand All @@ -155,6 +148,12 @@ class ApiKey extends Model
'r_' . AdminAcl::RESOURCE_SERVERS => 'integer|min:0|max:3',
];

protected $dates = [
self::CREATED_AT,
self::UPDATED_AT,
'last_used_at',
];

/**
* Returns the user this token is assigned to.
*/
Expand Down
5 changes: 4 additions & 1 deletion app/Models/Backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ class Backup extends Model
'is_locked' => 'bool',
'ignored_files' => 'array',
'bytes' => 'int',
'completed_at' => 'datetime',
];

protected $dates = [
'completed_at',
];

protected $attributes = [
Expand Down
10 changes: 8 additions & 2 deletions app/Models/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,14 @@ class Schedule extends Model
'is_active' => 'boolean',
'is_processing' => 'boolean',
'only_when_online' => 'boolean',
'last_run_at' => 'datetime',
'next_run_at' => 'datetime',
];

/**
* Columns to mutate to a date.
*/
protected $dates = [
'last_run_at',
'next_run_at',
];

protected $attributes = [
Expand Down
9 changes: 5 additions & 4 deletions app/Models/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ class Server extends Model
*/
protected $with = ['allocation'];

/**
* The attributes that should be mutated to dates.
*/
protected $dates = [self::CREATED_AT, self::UPDATED_AT, 'deleted_at', 'installed_at'];

/**
* Fields that are not mass assignable.
*/
Expand Down Expand Up @@ -197,10 +202,6 @@ class Server extends Model
'database_limit' => 'integer',
'allocation_limit' => 'integer',
'backup_limit' => 'integer',
self::CREATED_AT => 'datetime',
self::UPDATED_AT => 'datetime',
'deleted_at' => 'datetime',
'installed_at' => 'datetime',
];

/**
Expand Down
8 changes: 5 additions & 3 deletions app/Models/TaskLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ class TaskLog extends Model
'id' => 'integer',
'task_id' => 'integer',
'run_status' => 'integer',
'run_time' => 'datetime',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];

/**
* The attributes that should be mutated to dates.
*/
protected $dates = ['run_time', 'created_at', 'updated_at'];
}
3 changes: 2 additions & 1 deletion app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,10 @@ class User extends Model implements
'root_admin' => 'boolean',
'use_totp' => 'boolean',
'gravatar' => 'boolean',
'totp_authenticated_at' => 'datetime',
];

protected $dates = ['totp_authenticated_at'];

/**
* The attributes excluded from the model's JSON form.
*/
Expand Down
4 changes: 2 additions & 2 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AppServiceProvider extends ServiceProvider
/**
* Bootstrap any application services.
*/
public function boot(): void
public function boot()
{
Schema::defaultStringLength(191);

Expand Down Expand Up @@ -54,7 +54,7 @@ public function boot(): void
/**
* Register application service providers.
*/
public function register(): void
public function register()
{
// Only load the settings service provider if the environment
// is configured to allow it.
Expand Down
6 changes: 4 additions & 2 deletions app/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ class AuthServiceProvider extends ServiceProvider
Server::class => ServerPolicy::class,
];

public function boot(): void
public function boot()
{
Sanctum::usePersonalAccessTokenModel(ApiKey::class);

$this->registerPolicies();
}

public function register(): void
public function register()
{
Sanctum::ignoreMigrations();
}
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/BackupsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BackupsServiceProvider extends ServiceProvider implements DeferrableProvid
/**
* Register the S3 backup disk.
*/
public function register(): void
public function register()
{
$this->app->singleton(BackupManager::class, function ($app) {
return new BackupManager($app);
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/BladeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class BladeServiceProvider extends ServiceProvider
/**
* Perform post-registration booting of services.
*/
public function boot(): void
public function boot()
{
$this->app->make('blade.compiler')
->directive('datetimeHuman', function ($expression) {
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/BroadcastServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class BroadcastServiceProvider extends ServiceProvider
/**
* Bootstrap any application services.
*/
public function boot(): void
public function boot()
{
Broadcast::routes();

Expand Down
2 changes: 1 addition & 1 deletion app/Providers/HashidsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class HashidsServiceProvider extends ServiceProvider
/**
* Register the ability to use Hashids.
*/
public function register(): void
public function register()
{
$this->app->singleton(HashidsInterface::class, function () {
/** @var \Illuminate\Contracts\Config\Repository $config */
Expand Down
4 changes: 2 additions & 2 deletions app/Providers/RepositoryServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
class RepositoryServiceProvider extends ServiceProvider
{
/**
* Register all the repository bindings.
* Register all of the repository bindings.
*/
public function register(): void
public function register()
{
// Eloquent Repositories
$this->app->bind(AllocationRepositoryInterface::class, AllocationRepository::class);
Expand Down
4 changes: 2 additions & 2 deletions app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class RouteServiceProvider extends ServiceProvider
/**
* Define your route model bindings, pattern filters, etc.
*/
public function boot(): void
public function boot()
{
$this->configureRateLimiting();

Expand Down Expand Up @@ -68,7 +68,7 @@ public function boot(): void
/**
* Configure the rate limiters for the application.
*/
protected function configureRateLimiting(): void
protected function configureRateLimiting()
{
// Authentication rate limiting. For login and checkpoint endpoints we'll apply
// a limit of 10 requests per minute, for the forgot password endpoint apply a
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/SettingsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class SettingsServiceProvider extends ServiceProvider
/**
* Boot the service provider.
*/
public function boot(ConfigRepository $config, Encrypter $encrypter, Log $log, SettingsRepositoryInterface $settings): void
public function boot(ConfigRepository $config, Encrypter $encrypter, Log $log, SettingsRepositoryInterface $settings)
{
// Only set the email driver settings from the database if we
// are configured using SMTP as the driver.
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/ViewComposerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ViewComposerServiceProvider extends ServiceProvider
/**
* Register bindings in the container.
*/
public function boot(): void
public function boot()
{
$this->app->make('view')->composer('*', SettingComposer::class);
$this->app->make('view')->composer('*', StoreComposer::class);
Expand Down
1 change: 1 addition & 0 deletions app/Services/Servers/ServerDeletionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Pterodactyl\Services\Servers;

use Pterodactyl\Models\User;
use Illuminate\Http\Response;
use Pterodactyl\Models\Server;
use Illuminate\Support\Facades\Log;
Expand Down
Loading

0 comments on commit 5b13b9d

Please sign in to comment.