refactoring (#116)

- refactoring architecture
- fix incomplete ssh logs
- code editor for scripts in the app
- remove Jobs and SSHCommands
This commit is contained in:
Saeed Vaziry
2024-03-14 20:03:43 +01:00
committed by GitHub
parent cee4a70c3c
commit 428140b931
472 changed files with 24110 additions and 8159 deletions

View File

@ -2,8 +2,10 @@
namespace App\Actions\SSL;
use App\Enums\SslStatus;
use App\Enums\SslType;
use App\Models\Site;
use App\Models\Ssl;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
use Illuminate\Validation\ValidationException;
@ -17,13 +19,24 @@ public function create(Site $site, array $input): void
{
$this->validate($input);
if ($input['type'] == SslType::LETSENCRYPT) {
$site->createFreeSsl();
}
$ssl = new Ssl([
'site_id' => $site->id,
'type' => $input['type'],
'certificate' => $input['certificate'] ?? null,
'pk' => $input['private'] ?? null,
'expires_at' => $input['type'] === SslType::LETSENCRYPT ? now()->addMonths(3) : null,
'status' => SslStatus::CREATING,
]);
$ssl->save();
if ($input['type'] == SslType::CUSTOM) {
$site->createCustomSsl($input['certificate'], $input['private']);
}
dispatch(function () use ($site, $ssl) {
$site->server->webserver()->handler()->setupSSL($ssl);
$ssl->status = SslStatus::CREATED;
$ssl->save();
$site->type()->edit();
})->catch(function () use ($ssl) {
$ssl->delete();
});
}
/**

View File

@ -0,0 +1,14 @@
<?php
namespace App\Actions\SSL;
use App\Models\Ssl;
class DeleteSSL
{
public function delete(Ssl $ssl): void
{
$ssl->site->server->webserver()->handler()->removeSSL($ssl);
$ssl->delete();
}
}