Remove all of the old references to unused interfaces outside the test code
This commit is contained in:
parent
25f18dccdc
commit
60f6e86b8b
14 changed files with 44 additions and 683 deletions
|
@ -3,33 +3,25 @@
|
|||
namespace Pterodactyl\Jobs\Schedule;
|
||||
|
||||
use Exception;
|
||||
use Cake\Chronos\Chronos;
|
||||
use Carbon\Carbon;
|
||||
use Pterodactyl\Jobs\Job;
|
||||
use InvalidArgumentException;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Pterodactyl\Repositories\Eloquent\TaskRepository;
|
||||
use Pterodactyl\Repositories\Wings\DaemonPowerRepository;
|
||||
use Pterodactyl\Repositories\Wings\DaemonCommandRepository;
|
||||
use Pterodactyl\Contracts\Repository\TaskRepositoryInterface;
|
||||
use Pterodactyl\Services\DaemonKeys\DaemonKeyProviderService;
|
||||
use Pterodactyl\Contracts\Repository\ScheduleRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\Daemon\PowerRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\Daemon\CommandRepositoryInterface;
|
||||
|
||||
class RunTaskJob extends Job implements ShouldQueue
|
||||
{
|
||||
use DispatchesJobs, InteractsWithQueue, SerializesModels;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\Daemon\CommandRepositoryInterface
|
||||
*/
|
||||
protected $commandRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\Daemon\PowerRepositoryInterface
|
||||
*/
|
||||
protected $powerRepository;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
@ -41,7 +33,7 @@ class RunTaskJob extends Job implements ShouldQueue
|
|||
public $task;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\TaskRepositoryInterface
|
||||
* @var \Pterodactyl\Repositories\Eloquent\TaskRepository
|
||||
*/
|
||||
protected $taskRepository;
|
||||
|
||||
|
@ -61,28 +53,24 @@ class RunTaskJob extends Job implements ShouldQueue
|
|||
/**
|
||||
* Run the job and send actions to the daemon running the server.
|
||||
*
|
||||
* @param \Pterodactyl\Contracts\Repository\Daemon\CommandRepositoryInterface $commandRepository
|
||||
* @param \Pterodactyl\Repositories\Wings\DaemonCommandRepository $commandRepository
|
||||
* @param \Pterodactyl\Services\DaemonKeys\DaemonKeyProviderService $keyProviderService
|
||||
* @param \Pterodactyl\Contracts\Repository\Daemon\PowerRepositoryInterface $powerRepository
|
||||
* @param \Pterodactyl\Contracts\Repository\TaskRepositoryInterface $taskRepository
|
||||
* @param \Pterodactyl\Repositories\Wings\DaemonPowerRepository $powerRepository
|
||||
* @param \Pterodactyl\Repositories\Eloquent\TaskRepository $taskRepository
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\Daemon\InvalidPowerSignalException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function handle(
|
||||
CommandRepositoryInterface $commandRepository,
|
||||
DaemonCommandRepository $commandRepository,
|
||||
DaemonKeyProviderService $keyProviderService,
|
||||
PowerRepositoryInterface $powerRepository,
|
||||
TaskRepositoryInterface $taskRepository
|
||||
DaemonPowerRepository $powerRepository,
|
||||
TaskRepository $taskRepository
|
||||
) {
|
||||
$this->commandRepository = $commandRepository;
|
||||
$this->powerRepository = $powerRepository;
|
||||
$this->taskRepository = $taskRepository;
|
||||
|
||||
$task = $this->taskRepository->getTaskForJobProcess($this->task);
|
||||
$server = $task->getRelation('server');
|
||||
$user = $server->getRelation('user');
|
||||
|
||||
// Do not process a task that is not set to active.
|
||||
if (! $task->getRelation('schedule')->is_active) {
|
||||
|
@ -95,14 +83,10 @@ class RunTaskJob extends Job implements ShouldQueue
|
|||
// Perform the provided task against the daemon.
|
||||
switch ($task->action) {
|
||||
case 'power':
|
||||
$this->powerRepository->setServer($server)
|
||||
->setToken($keyProviderService->handle($server, $user))
|
||||
->sendSignal($task->payload);
|
||||
$powerRepository->setServer($server)->send($task->payload);
|
||||
break;
|
||||
case 'command':
|
||||
$this->commandRepository->setServer($server)
|
||||
->setToken($keyProviderService->handle($server, $user))
|
||||
->send($task->payload);
|
||||
$commandRepository->setServer($server)->send($task->payload);
|
||||
break;
|
||||
default:
|
||||
throw new InvalidArgumentException('Cannot run a task that points to a non-existent action.');
|
||||
|
@ -115,10 +99,7 @@ class RunTaskJob extends Job implements ShouldQueue
|
|||
/**
|
||||
* Handle a failure while sending the action to the daemon or otherwise processing the job.
|
||||
*
|
||||
* @param null|\Exception $exception
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @param \Exception|null $exception
|
||||
*/
|
||||
public function failed(Exception $exception = null)
|
||||
{
|
||||
|
@ -149,28 +130,25 @@ class RunTaskJob extends Job implements ShouldQueue
|
|||
|
||||
/**
|
||||
* Marks the parent schedule as being complete.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
private function markScheduleComplete()
|
||||
{
|
||||
$repository = app()->make(ScheduleRepositoryInterface::class);
|
||||
$repository->withoutFreshModel()->update($this->schedule, [
|
||||
'is_processing' => false,
|
||||
'last_run_at' => Chronos::now()->toDateTimeString(),
|
||||
]);
|
||||
Container::getInstance()
|
||||
->make(ScheduleRepositoryInterface::class)
|
||||
->withoutFreshModel()
|
||||
->update($this->schedule, [
|
||||
'is_processing' => false,
|
||||
'last_run_at' => Carbon::now()->toDateTimeString(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark a specific task as no longer being queued.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
private function markTaskNotQueued()
|
||||
{
|
||||
$repository = app()->make(TaskRepositoryInterface::class);
|
||||
$repository->update($this->task, ['is_queued' => false]);
|
||||
Container::getInstance()
|
||||
->make(TaskRepositoryInterface::class)
|
||||
->update($this->task, ['is_queued' => false]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue