refactoring - remove unused code

This commit is contained in:
Saeed Vaziry
2024-03-06 20:33:33 +01:00
parent cfc0645002
commit 9d705592da
32 changed files with 3 additions and 442 deletions

View File

@ -2,7 +2,6 @@
namespace App\Jobs\Installation;
use App\Events\Broadcast;
use App\Models\Server;
class ContinueInstallation extends InstallationJob
@ -29,11 +28,6 @@ public function handle(): void
$this->server->update([
'status' => 'installation_failed',
]);
event(
new Broadcast('install-server-failed', [
'server' => $this->server,
])
);
return;
}

View File

@ -2,7 +2,6 @@
namespace App\Jobs\PHP;
use App\Events\Broadcast;
use App\Exceptions\ProcessFailed;
use App\Jobs\Job;
use App\Models\Service;
@ -40,19 +39,9 @@ public function handle(): void
$typeData['extensions'][] = $this->name;
$this->service->type_data = $typeData;
$this->service->save();
event(
new Broadcast('install-php-extension-finished', [
'service' => $this->service,
])
);
}
public function failed(): void
{
event(
new Broadcast('install-php-extension-failed', [
'service' => $this->service,
])
);
}
}

View File

@ -3,7 +3,6 @@
namespace App\Jobs\Queue;
use App\Enums\QueueStatus;
use App\Events\Broadcast;
use App\Jobs\Job;
use App\Models\Queue;
@ -30,20 +29,10 @@ public function handle(): void
);
$this->worker->status = QueueStatus::RUNNING;
$this->worker->save();
event(
new Broadcast('deploy-queue-finished', [
'queue' => $this->worker,
])
);
}
public function failed(): void
{
$this->worker->delete();
event(
new Broadcast('deploy-queue-failed', [
'queue' => $this->worker,
])
);
}
}

View File

@ -2,7 +2,6 @@
namespace App\Jobs\Queue;
use App\Events\Broadcast;
use App\Jobs\Job;
use App\Models\Queue;
@ -18,20 +17,10 @@ public function __construct(Queue $worker)
public function handle(): void
{
$logs = $this->worker->server->processManager()->handler()->getLogs($this->worker->log_file);
event(
new Broadcast('get-logs-finished', [
'id' => $this->worker->id,
'logs' => $logs,
])
);
}
public function failed(): void
{
event(
new Broadcast('get-logs-failed', [
'message' => __('Failed to download the logs!'),
])
);
}
}

View File

@ -2,7 +2,6 @@
namespace App\Jobs\Queue;
use App\Events\Broadcast;
use App\Jobs\Job;
use App\Models\Queue;
@ -47,22 +46,11 @@ public function handle(): void
}
$this->worker->status = $this->successStatus;
$this->worker->save();
event(
new Broadcast('manage-queue-finished', [
'queue' => $this->worker,
])
);
}
public function failed(): void
{
$this->worker->status = $this->failStatus;
$this->worker->save();
event(
new Broadcast('manage-queue-failed', [
'message' => $this->failMessage,
'queue' => $this->worker,
])
);
}
}

View File

@ -3,7 +3,6 @@
namespace App\Jobs\Queue;
use App\Enums\QueueStatus;
use App\Events\Broadcast;
use App\Jobs\Job;
use App\Models\Queue;
@ -20,22 +19,11 @@ public function handle(): void
{
$this->worker->server->processManager()->handler()->delete($this->worker->id, $this->worker->site_id);
$this->worker->delete();
event(
new Broadcast('remove-queue-finished', [
'id' => $this->worker->id,
])
);
}
public function failed(): void
{
$this->worker->status = QueueStatus::FAILED;
$this->worker->save();
event(
new Broadcast('remove-queue-failed', [
'message' => __('Failed to delete worker!'),
'id' => $this->worker->id,
])
);
}
}

View File

@ -2,7 +2,6 @@
namespace App\Jobs\Redirect;
use App\Events\Broadcast;
use App\Jobs\Job;
use App\Models\Redirect;
@ -22,21 +21,11 @@ public function handle(): void
$this->redirect->site->server->webserver()->handler()->updateRedirects($this->redirect->site, $redirects);
$this->redirect->status = 'ready';
$this->redirect->save();
event(
new Broadcast('create-redirect-finished', [
'redirect' => $this->redirect,
])
);
}
public function failed(): void
{
$this->redirect->status = 'failed';
$this->redirect->delete();
event(
new Broadcast('create-redirect-failed', [
'redirect' => $this->redirect,
])
);
}
}

View File

@ -2,7 +2,6 @@
namespace App\Jobs\Redirect;
use App\Events\Broadcast;
use App\Jobs\Job;
use App\Models\Redirect;
@ -24,21 +23,11 @@ public function handle(): void
->get();
$this->redirect->site->server->webserver()->handler()->updateRedirects($this->redirect->site, $redirects);
$this->redirect->delete();
event(
new Broadcast('delete-redirect-finished', [
'id' => $this->redirect->id,
])
);
}
public function failed(): void
{
$this->redirect->status = 'failed';
$this->redirect->save();
event(
new Broadcast('delete-redirect-failed', [
'redirect' => $this->redirect,
])
);
}
}

View File

@ -2,7 +2,6 @@
namespace App\Jobs\Script;
use App\Events\Broadcast;
use App\Jobs\Job;
use App\Models\Script;
use App\Models\ScriptExecution;
@ -41,21 +40,11 @@ public function handle(): void
);
$this->scriptExecution->finished_at = now();
$this->scriptExecution->save();
event(
new Broadcast('execute-script-finished', [
'execution' => $this->scriptExecution,
])
);
}
public function failed(): void
{
$this->scriptExecution->finished_at = now();
$this->scriptExecution->save();
event(
new Broadcast('execute-script-failed', [
'execution' => $this->scriptExecution,
])
);
}
}

View File

@ -2,7 +2,6 @@
namespace App\Jobs\Service;
use App\Events\Broadcast;
use App\Jobs\Job;
use App\Models\Service;
use App\SSHCommands\Service\RestartServiceCommand;
@ -54,22 +53,11 @@ public function handle(): void
);
$this->service->status = $this->successStatus;
$this->service->save();
event(
new Broadcast('update-service-finished', [
'service' => $this->service,
])
);
}
public function failed(): void
{
$this->service->status = $this->failStatus;
$this->service->save();
event(
new Broadcast('update-service-failed', [
'message' => $this->service->name.' '.$this->failMessage,
'service' => $this->service,
])
);
}
}

View File

@ -3,7 +3,6 @@
namespace App\Jobs\Site;
use App\Enums\SiteStatus;
use App\Events\Broadcast;
use App\Jobs\Job;
use App\Models\Site;
@ -20,21 +19,11 @@ public function handle(): void
{
$this->site->server->webserver()->handler()->deleteSite($this->site);
$this->site->delete();
event(
new Broadcast('delete-site-finished', [
'site' => $this->site,
])
);
}
public function failed(): void
{
$this->site->status = SiteStatus::READY;
$this->site->save();
event(
new Broadcast('delete-site-failed', [
'site' => $this->site,
])
);
}
}

View File

@ -3,7 +3,6 @@
namespace App\Jobs\Site;
use App\Enums\DeploymentStatus;
use App\Events\Broadcast;
use App\Jobs\Job;
use App\Models\Deployment;
use App\SSHCommands\System\RunScriptCommand;
@ -39,11 +38,6 @@ public function handle(): void
$this->deployment->status = DeploymentStatus::FINISHED;
$this->deployment->log_id = $ssh->log->id;
$this->deployment->save();
event(
new Broadcast('deploy-site-finished', [
'deployment' => $this->deployment,
])
);
} catch (Throwable) {
$this->deployment->log_id = $ssh->log->id;
$this->deployment->save();
@ -55,10 +49,5 @@ public function failed(): void
{
$this->deployment->status = DeploymentStatus::FAILED;
$this->deployment->save();
event(
new Broadcast('deploy-site-failed', [
'deployment' => $this->deployment,
])
);
}
}

View File

@ -2,7 +2,6 @@
namespace App\Jobs\Site;
use App\Events\Broadcast;
use App\Jobs\Job;
use App\Models\Site;
use App\SSHCommands\System\EditFileCommand;
@ -28,19 +27,9 @@ public function handle(): void
$this->site->env
)
);
event(
new Broadcast('deploy-site-env-finished', [
'site' => $this->site,
])
);
}
public function failed(): void
{
event(
new Broadcast('deploy-site-env-failed', [
'site' => $this->site,
])
);
}
}

View File

@ -2,7 +2,6 @@
namespace App\Jobs\Site;
use App\Events\Broadcast;
use App\Jobs\Job;
use App\Models\Site;
use App\SSHCommands\Website\UpdateBranchCommand;
@ -35,19 +34,9 @@ public function handle(): void
);
$this->site->branch = $this->branch;
$this->site->save();
event(
new Broadcast('update-branch-finished', [
'site' => $this->site,
])
);
}
public function failed(): void
{
event(
new Broadcast('update-branch-failed', [
'site' => $this->site,
])
);
}
}

View File

@ -2,7 +2,6 @@
namespace App\Jobs\SshKey;
use App\Events\Broadcast;
use App\Jobs\Job;
use App\Models\Server;
use App\Models\SshKey;
@ -31,20 +30,10 @@ public function handle()
'delete-ssh-key'
);
$this->server->sshKeys()->detach($this->sshKey);
event(
new Broadcast('delete-ssh-key-finished', [
'sshKey' => $this->sshKey,
])
);
}
public function failed(): void
{
$this->server->sshKeys()->attach($this->sshKey);
event(
new Broadcast('delete-ssh-key-failed', [
'sshKey' => $this->sshKey,
])
);
}
}

View File

@ -3,7 +3,6 @@
namespace App\Jobs\SshKey;
use App\Enums\SshKeyStatus;
use App\Events\Broadcast;
use App\Jobs\Job;
use App\Models\Server;
use App\Models\SshKey;
@ -34,20 +33,10 @@ public function handle(): void
$this->sshKey->servers()->updateExistingPivot($this->server->id, [
'status' => SshKeyStatus::ADDED,
]);
event(
new Broadcast('deploy-ssh-key-finished', [
'sshKey' => $this->sshKey,
])
);
}
public function failed(): void
{
$this->server->sshKeys()->detach($this->sshKey);
event(
new Broadcast('deploy-ssh-key-failed', [
'sshKey' => $this->sshKey,
])
);
}
}

View File

@ -4,7 +4,6 @@
use App\Enums\SiteType;
use App\Enums\SslStatus;
use App\Events\Broadcast;
use App\Jobs\Job;
use App\Models\Ssl;
@ -22,11 +21,6 @@ public function handle(): void
$this->ssl->site->server->webserver()->handler()->setupSSL($this->ssl);
$this->ssl->status = SslStatus::CREATED;
$this->ssl->save();
event(
new Broadcast('deploy-ssl-finished', [
'ssl' => $this->ssl,
])
);
if ($this->ssl->site->type == SiteType::WORDPRESS) {
$typeData = $this->ssl->site->type_data;
$typeData['url'] = $this->ssl->site->url;
@ -38,11 +32,6 @@ public function handle(): void
public function failed(): void
{
event(
new Broadcast('deploy-ssl-failed', [
'ssl' => $this->ssl,
])
);
$this->ssl->delete();
}
}

View File

@ -2,7 +2,6 @@
namespace App\Jobs\Ssl;
use App\Events\Broadcast;
use App\Jobs\Job;
use App\Models\Ssl;
@ -19,21 +18,11 @@ public function handle(): void
{
$this->ssl->site->server->webserver()->handler()->removeSSL($this->ssl);
$this->ssl->delete();
event(
new Broadcast('remove-ssl-finished', [
'ssl' => $this->ssl,
])
);
}
public function failed(): void
{
$this->ssl->status = 'failed';
$this->ssl->save();
event(
new Broadcast('remove-ssl-failed', [
'ssl' => $this->ssl,
])
);
}
}