From f77df5b732858a0b466bcf5d001f86bac0d5a6c3 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 15 Sep 2023 21:13:50 +0200 Subject: [PATCH 1/2] feat: sentry add email for better support --- app/Exceptions/Handler.php | 5 +++-- config/sentry.php | 3 +-- config/version.php | 2 +- versions.json | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 9bfde1793..19f47f30b 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -3,6 +3,7 @@ namespace App\Exceptions; use App\Models\InstanceSettings; +use App\Models\User; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Sentry\Laravel\Integration; use Sentry\State\Scope; @@ -56,8 +57,8 @@ public function register(): void function (Scope $scope) { $scope->setUser( [ - 'id' => config('sentry.server_name'), - 'email' => auth()->user()->email + 'email' => auth()->user()->email, + 'instanceAdmin' => User::find(0)->email ] ); } diff --git a/config/sentry.php b/config/sentry.php index fa2378cb0..9e80be3b7 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,8 +7,7 @@ // The release version of your application // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) - 'release' => '4.0.0-beta.38', - 'server_name' => env('APP_ID', 'coolify'), + 'release' => '4.0.0-beta.39', // When left empty or `null` the Laravel environment will be used 'environment' => config('app.env'), diff --git a/config/version.php b/config/version.php index e1d830d38..8d1293e1f 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ Date: Sat, 16 Sep 2023 16:49:33 +0200 Subject: [PATCH 2/2] fix: localhost --- app/Http/Livewire/Boarding/Index.php | 46 ++++++++++++++++------------ 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/app/Http/Livewire/Boarding/Index.php b/app/Http/Livewire/Boarding/Index.php index 0a20c68fc..dace2eb94 100644 --- a/app/Http/Livewire/Boarding/Index.php +++ b/app/Http/Livewire/Boarding/Index.php @@ -89,7 +89,7 @@ public function setServerType(string $type) if (!$this->createdServer) { return $this->emit('error', 'Localhost server is not found. Something went wrong during installation. Please try to reinstall or contact support.'); } - return $this->validateServer(); + return $this->validateServer('localhost'); } elseif ($type === 'remote') { $this->privateKeys = PrivateKey::ownedByCurrentTeam(['name'])->where('id', '!=', 0)->get(); if ($this->privateKeys->count() > 0) { @@ -185,7 +185,7 @@ public function saveServer() $this->validateServer(); } - public function validateServer() + public function validateServer(?string $type = null) { try { $customErrorMessage = "Server is not reachable:"; @@ -197,24 +197,30 @@ public function validateServer() throw new \Exception('No Docker Engine or older than 23 version installed.'); } $customErrorMessage = "Cannot create Server or Private Key. Please try again."; - $createdPrivateKey = PrivateKey::create([ - 'name' => $this->privateKeyName, - 'description' => $this->privateKeyDescription, - 'private_key' => $this->privateKey, - 'team_id' => currentTeam()->id - ]); - $server = Server::create([ - 'name' => $this->remoteServerName, - 'ip' => $this->remoteServerHost, - 'port' => $this->remoteServerPort, - 'user' => $this->remoteServerUser, - 'description' => $this->remoteServerDescription, - 'private_key_id' => $createdPrivateKey->id, - 'team_id' => currentTeam()->id, - ]); - $server->settings->is_reachable = true; - $server->settings->is_usable = true; - $server->settings->save(); + if ($type !== 'localhost') { + $createdPrivateKey = PrivateKey::create([ + 'name' => $this->privateKeyName, + 'description' => $this->privateKeyDescription, + 'private_key' => $this->privateKey, + 'team_id' => currentTeam()->id + ]); + $server = Server::create([ + 'name' => $this->remoteServerName, + 'ip' => $this->remoteServerHost, + 'port' => $this->remoteServerPort, + 'user' => $this->remoteServerUser, + 'description' => $this->remoteServerDescription, + 'private_key_id' => $createdPrivateKey->id, + 'team_id' => currentTeam()->id, + ]); + $server->settings->is_reachable = true; + $server->settings->is_usable = true; + $server->settings->save(); + } else { + $this->createdServer->settings->update([ + 'is_reachable' => true, + ]); + } $this->getProxyType(); } catch (\Throwable $e) { return handleError(error: $e, customErrorMessage: $customErrorMessage, livewire: $this);