From 9f4356f67dfccdf5a0567f2ba4403780492d3857 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 8 Sep 2023 16:28:56 +0200 Subject: [PATCH 01/12] version++ --- config/sentry.php | 2 +- config/version.php | 2 +- versions.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/sentry.php b/config/sentry.php index d8316f2a6..38749f3a4 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ return [ // 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.28', + 'release' => '4.0.0-beta.29', 'server_name' => env('APP_ID', 'coolify'), // 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 6ded6b968..c9f3c92a2 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ Date: Fri, 8 Sep 2023 16:46:53 +0200 Subject: [PATCH 02/12] fix: ui --- resources/views/livewire/notifications/email-settings.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/livewire/notifications/email-settings.blade.php b/resources/views/livewire/notifications/email-settings.blade.php index 1deab9f68..f80acf03c 100644 --- a/resources/views/livewire/notifications/email-settings.blade.php +++ b/resources/views/livewire/notifications/email-settings.blade.php @@ -41,8 +41,8 @@ label="Use hosted email service (Pro+ subscription required)" /> @endif -

Custom Email Service

@if (!$team->use_instance_email_settings) +

Custom Email Service

Date: Fri, 8 Sep 2023 16:53:19 +0200 Subject: [PATCH 03/12] fix: retry notifications --- app/Notifications/Application/DeploymentFailed.php | 1 + app/Notifications/Application/DeploymentSuccess.php | 1 + app/Notifications/Application/StatusChanged.php | 1 + app/Notifications/Database/BackupFailed.php | 1 + app/Notifications/Database/BackupSuccess.php | 1 + app/Notifications/Internal/GeneralNotification.php | 1 + app/Notifications/Server/NotReachable.php | 1 + app/Notifications/Test.php | 1 + app/Notifications/TransactionalEmails/InvitationLink.php | 1 + app/Notifications/TransactionalEmails/Test.php | 1 + 10 files changed, 10 insertions(+) diff --git a/app/Notifications/Application/DeploymentFailed.php b/app/Notifications/Application/DeploymentFailed.php index ddbdf1446..ea9e05652 100644 --- a/app/Notifications/Application/DeploymentFailed.php +++ b/app/Notifications/Application/DeploymentFailed.php @@ -16,6 +16,7 @@ class DeploymentFailed extends Notification implements ShouldQueue { use Queueable; + public $tries = 5; public Application $application; public string $deployment_uuid; public ?ApplicationPreview $preview = null; diff --git a/app/Notifications/Application/DeploymentSuccess.php b/app/Notifications/Application/DeploymentSuccess.php index f46c44c0e..0705e11ae 100644 --- a/app/Notifications/Application/DeploymentSuccess.php +++ b/app/Notifications/Application/DeploymentSuccess.php @@ -16,6 +16,7 @@ class DeploymentSuccess extends Notification implements ShouldQueue { use Queueable; + public $tries = 5; public Application $application; public string $deployment_uuid; public ApplicationPreview|null $preview = null; diff --git a/app/Notifications/Application/StatusChanged.php b/app/Notifications/Application/StatusChanged.php index 0d01d08ab..11bd9f524 100644 --- a/app/Notifications/Application/StatusChanged.php +++ b/app/Notifications/Application/StatusChanged.php @@ -14,6 +14,7 @@ class StatusChanged extends Notification implements ShouldQueue { use Queueable; + public $tries = 5; public $application; public string $application_name; diff --git a/app/Notifications/Database/BackupFailed.php b/app/Notifications/Database/BackupFailed.php index 613b0846c..960232f9c 100644 --- a/app/Notifications/Database/BackupFailed.php +++ b/app/Notifications/Database/BackupFailed.php @@ -14,6 +14,7 @@ class BackupFailed extends Notification implements ShouldQueue { use Queueable; + public $tries = 5; public string $name; public string $frequency; diff --git a/app/Notifications/Database/BackupSuccess.php b/app/Notifications/Database/BackupSuccess.php index eb6d07c25..bac96ae35 100644 --- a/app/Notifications/Database/BackupSuccess.php +++ b/app/Notifications/Database/BackupSuccess.php @@ -14,6 +14,7 @@ class BackupSuccess extends Notification implements ShouldQueue { use Queueable; + public $tries = 5; public string $name; public string $frequency; diff --git a/app/Notifications/Internal/GeneralNotification.php b/app/Notifications/Internal/GeneralNotification.php index 78a76c059..024175622 100644 --- a/app/Notifications/Internal/GeneralNotification.php +++ b/app/Notifications/Internal/GeneralNotification.php @@ -12,6 +12,7 @@ class GeneralNotification extends Notification implements ShouldQueue { use Queueable; + public $tries = 5; public function __construct(public string $message) { } diff --git a/app/Notifications/Server/NotReachable.php b/app/Notifications/Server/NotReachable.php index 083808224..672636c57 100644 --- a/app/Notifications/Server/NotReachable.php +++ b/app/Notifications/Server/NotReachable.php @@ -15,6 +15,7 @@ class NotReachable extends Notification implements ShouldQueue { use Queueable; + public $tries = 5; public function __construct(public Server $server) { diff --git a/app/Notifications/Test.php b/app/Notifications/Test.php index 0b47d74b2..fbbd7a1fb 100644 --- a/app/Notifications/Test.php +++ b/app/Notifications/Test.php @@ -14,6 +14,7 @@ class Test extends Notification implements ShouldQueue { use Queueable; + public $tries = 5; public function __construct(public string|null $emails = null) { } diff --git a/app/Notifications/TransactionalEmails/InvitationLink.php b/app/Notifications/TransactionalEmails/InvitationLink.php index 96157c7e6..ab7cfb122 100644 --- a/app/Notifications/TransactionalEmails/InvitationLink.php +++ b/app/Notifications/TransactionalEmails/InvitationLink.php @@ -15,6 +15,7 @@ class InvitationLink extends Notification implements ShouldQueue { use Queueable; + public $tries = 5; public function via(): array { return [TransactionalEmailChannel::class]; diff --git a/app/Notifications/TransactionalEmails/Test.php b/app/Notifications/TransactionalEmails/Test.php index 3f3a009bb..21cf87470 100644 --- a/app/Notifications/TransactionalEmails/Test.php +++ b/app/Notifications/TransactionalEmails/Test.php @@ -12,6 +12,7 @@ class Test extends Notification implements ShouldQueue { use Queueable; + public $tries = 5; public function __construct(public string $emails) { } From 49f86621f460a871d8c7e638bba6597ea03f43b3 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 8 Sep 2023 16:56:14 +0200 Subject: [PATCH 04/12] fix: instance email settings --- app/Http/Livewire/Settings/Email.php | 11 +++++++++-- resources/views/livewire/settings/email.blade.php | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/Http/Livewire/Settings/Email.php b/app/Http/Livewire/Settings/Email.php index c0e80f020..878b1133f 100644 --- a/app/Http/Livewire/Settings/Email.php +++ b/app/Http/Livewire/Settings/Email.php @@ -60,7 +60,6 @@ class Email extends Component $this->validate([ 'settings.resend_api_key' => 'required' ]); - $this->settings->smtp_enabled = false; $this->settings->save(); $this->emit('success', 'Settings saved successfully.'); } catch (\Exception $e) { @@ -68,9 +67,18 @@ class Email extends Component return general_error_handler($e, $this); } } + public function instantSaveResend() { + try { + $this->settings->smtp_enabled = false; + $this->submitResend(); + } catch (\Exception $e) { + return general_error_handler($e, $this); + } + } public function instantSave() { try { + $this->settings->resend_enabled = false; $this->submit(); } catch (\Exception $e) { return general_error_handler($e, $this); @@ -89,7 +97,6 @@ class Email extends Component 'settings.smtp_password' => 'nullable', 'settings.smtp_timeout' => 'nullable', ]); - $this->settings->resend_enabled = false; $this->settings->save(); $this->emit('success', 'Settings saved successfully.'); } catch (\Exception $e) { diff --git a/resources/views/livewire/settings/email.blade.php b/resources/views/livewire/settings/email.blade.php index 45ea814c3..3350541e5 100644 --- a/resources/views/livewire/settings/email.blade.php +++ b/resources/views/livewire/settings/email.blade.php @@ -67,7 +67,7 @@
Resend
- +
From 2e855e030f47333f753abddba574ff2a38373780 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 8 Sep 2023 16:59:49 +0200 Subject: [PATCH 05/12] fix: ui --- .../notifications/discord-settings.blade.php | 33 ++++++++++++------- .../notifications/email-settings.blade.php | 31 ++++++++++------- 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/resources/views/livewire/notifications/discord-settings.blade.php b/resources/views/livewire/notifications/discord-settings.blade.php index b8b10e443..cfba9d92f 100644 --- a/resources/views/livewire/notifications/discord-settings.blade.php +++ b/resources/views/livewire/notifications/discord-settings.blade.php @@ -20,20 +20,31 @@ id="team.discord_webhook_url" label="Webhook" /> @if (data_get($team, 'discord_enabled')) -

Subscribe to events

+

Subscribe to events

+ + @if (isDev()) - +

Test

+
+ +
@endif -

General

- -

Applications

- -

Databases

- +

Container Status Changes

+
+ +
+

Application Deployments

+
+ +
+

Backup Status

+
+ +
@endif
diff --git a/resources/views/livewire/notifications/email-settings.blade.php b/resources/views/livewire/notifications/email-settings.blade.php index f80acf03c..d1d3b9fc4 100644 --- a/resources/views/livewire/notifications/email-settings.blade.php +++ b/resources/views/livewire/notifications/email-settings.blade.php @@ -42,7 +42,6 @@ @endif @if (!$team->use_instance_email_settings) -

Custom Email Service

@endif @if (isEmailEnabled($team) || data_get($team, 'use_instance_email_settings')) -

Subscribe to events

+

Subscribe to events

@if (isDev()) - +

Test

+
+ +
@endif -

General

- -

Applications

- -

Databases

- +

Container Status Changes

+
+ +
+

Application Deployments

+
+ +
+

Backup Status

+
+ +
@endif From f6c3fe78883842d916818ba75d068ce9174e523c Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 8 Sep 2023 17:26:59 +0200 Subject: [PATCH 06/12] fix: test email on for admins or custom smtp --- .../notifications/email-settings.blade.php | 26 +++++++++---------- .../views/livewire/settings/email.blade.php | 15 ++++++----- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/resources/views/livewire/notifications/email-settings.blade.php b/resources/views/livewire/notifications/email-settings.blade.php index d1d3b9fc4..d7acaac1a 100644 --- a/resources/views/livewire/notifications/email-settings.blade.php +++ b/resources/views/livewire/notifications/email-settings.blade.php @@ -21,7 +21,7 @@ Copy from Instance Settings @endif - @if (isEmailEnabled($team) || data_get($team, 'use_instance_email_settings')) + @if (isEmailEnabled($team) && auth()->user()->isAdminFromSession()) Send Test Email @@ -36,10 +36,10 @@ label="Use hosted email service" /> @else -
- -
+
+ +
@endif @if (!$team->use_instance_email_settings) @@ -112,25 +112,23 @@

Subscribe to events

@if (isDev()) -

Test

-
- -
+

Test

+
+ +
@endif

Container Status Changes

- +

Application Deployments

- +

Backup Status

+ label="Enabled" />
@endif diff --git a/resources/views/livewire/settings/email.blade.php b/resources/views/livewire/settings/email.blade.php index 3350541e5..0f7fd65bf 100644 --- a/resources/views/livewire/settings/email.blade.php +++ b/resources/views/livewire/settings/email.blade.php @@ -22,12 +22,12 @@ Save - @if ($settings->resend_enabled || $settings->smtp_enabled) - - Send Test Email - - @endif + @if (isEmailEnabled($settings)) + + Send Test Email + + @endif
@@ -74,7 +74,8 @@
- +
From b17c09f7a74878894d7974b87b0dc7ff84c08c30 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 8 Sep 2023 17:31:02 +0200 Subject: [PATCH 07/12] update testemail command --- app/Console/Commands/TestEmail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/TestEmail.php b/app/Console/Commands/TestEmail.php index e876b62a0..50312d553 100644 --- a/app/Console/Commands/TestEmail.php +++ b/app/Console/Commands/TestEmail.php @@ -31,7 +31,7 @@ class TestEmail extends Command * * @var string */ - protected $signature = 'email:test'; + protected $signature = 'email:test {to}'; /** * The console command description. @@ -176,7 +176,7 @@ class TestEmail extends Command 'internal@example.com', 'Test Email', ) - ->to('test@example.com') + ->to($this->argument('to') ?? 'test@example.com') ->subject($this->mail->subject) ->html((string)$this->mail->render()) ); From b82353d5e2e774a4d998eacad2627fe0532f9d9c Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 8 Sep 2023 17:42:08 +0200 Subject: [PATCH 08/12] update testemail command --- app/Console/Commands/TestEmail.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/Console/Commands/TestEmail.php b/app/Console/Commands/TestEmail.php index 50312d553..38a9b0c2a 100644 --- a/app/Console/Commands/TestEmail.php +++ b/app/Console/Commands/TestEmail.php @@ -23,6 +23,7 @@ use Mail; use Str; use function Laravel\Prompts\select; +use function Laravel\Prompts\text; class TestEmail extends Command { @@ -31,7 +32,7 @@ class TestEmail extends Command * * @var string */ - protected $signature = 'email:test {to}'; + protected $signature = 'email:test'; /** * The console command description. @@ -44,9 +45,10 @@ class TestEmail extends Command * Execute the console command. */ private ?MailMessage $mail = null; + private string $email = 'andras.bacsai@protonmail.com'; public function handle() { - $email = select( + $type = select( 'Which Email should be sent?', options: [ 'emails-test' => 'Test', @@ -60,15 +62,15 @@ class TestEmail extends Command 'waitlist-confirmation' => 'Waitlist Confirmation', ], ); - $type = set_transanctional_email_settings(); - if (!$type) { - throw new Exception('No email settings found.'); - } + $this->email = text('Email Address to send to'); + set_transanctional_email_settings(); + $this->mail = new MailMessage(); $this->mail->subject("Test Email"); - switch ($email) { + switch ($type) { case 'emails-test': $this->mail = (new Test())->toMail(); + $this->sendEmail(); break; case 'application-deployment-success': $application = Application::all()->first(); @@ -176,7 +178,7 @@ class TestEmail extends Command 'internal@example.com', 'Test Email', ) - ->to($this->argument('to') ?? 'test@example.com') + ->to($this->email) ->subject($this->mail->subject) ->html((string)$this->mail->render()) ); From 0d1a2aa5d130bb40507227927d5d711dbcca98d1 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 8 Sep 2023 17:51:19 +0200 Subject: [PATCH 09/12] update testemail command --- app/Console/Commands/TestEmail.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/Console/Commands/TestEmail.php b/app/Console/Commands/TestEmail.php index 38a9b0c2a..435cd59b2 100644 --- a/app/Console/Commands/TestEmail.php +++ b/app/Console/Commands/TestEmail.php @@ -174,10 +174,6 @@ class TestEmail extends Command [], [], fn (Message $message) => $message - ->from( - 'internal@example.com', - 'Test Email', - ) ->to($this->email) ->subject($this->mail->subject) ->html((string)$this->mail->render()) From 45b597bbab736bb0a4d06e0bd700b5cf606a3100 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 8 Sep 2023 18:33:26 +0200 Subject: [PATCH 10/12] feat: cache team settings --- app/Http/Livewire/Boarding/Index.php | 4 +++- app/Http/Livewire/SwitchTeam.php | 2 +- app/Http/Middleware/IsBoardingFlow.php | 2 +- app/Models/User.php | 5 ++++- bootstrap/helpers/shared.php | 10 ++++++++-- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/Http/Livewire/Boarding/Index.php b/app/Http/Livewire/Boarding/Index.php index 35f7fd218..c68cd8a50 100644 --- a/app/Http/Livewire/Boarding/Index.php +++ b/app/Http/Livewire/Boarding/Index.php @@ -6,6 +6,7 @@ use App\Actions\Server\InstallDocker; use App\Models\PrivateKey; use App\Models\Project; use App\Models\Server; +use App\Models\Team; use Illuminate\Support\Collection; use Livewire\Component; @@ -70,9 +71,10 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA== } public function skipBoarding() { - currentTeam()->update([ + Team::find(currentTeam()->id)->update([ 'show_boarding' => false ]); + ray(currentTeam()); refreshSession(); return redirect()->route('dashboard'); } diff --git a/app/Http/Livewire/SwitchTeam.php b/app/Http/Livewire/SwitchTeam.php index 087a7ad84..9a9b4c795 100644 --- a/app/Http/Livewire/SwitchTeam.php +++ b/app/Http/Livewire/SwitchTeam.php @@ -23,7 +23,7 @@ class SwitchTeam extends Component if (!$team_to_switch_to) { return; } - session(['currentTeam' => $team_to_switch_to]); + refreshSession($team_to_switch_to); return redirect(request()->header('Referer')); } } diff --git a/app/Http/Middleware/IsBoardingFlow.php b/app/Http/Middleware/IsBoardingFlow.php index 5858fe191..e0542a57a 100644 --- a/app/Http/Middleware/IsBoardingFlow.php +++ b/app/Http/Middleware/IsBoardingFlow.php @@ -15,7 +15,7 @@ class IsBoardingFlow */ public function handle(Request $request, Closure $next): Response { - // ray()->showQueries()->color('orange'); + ray()->showQueries()->color('orange'); if (showBoarding() && !in_array($request->path(), allowedPathsForBoardingAccounts())) { return redirect('boarding'); } diff --git a/app/Models/User.php b/app/Models/User.php index 9050de214..1671db496 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -4,6 +4,7 @@ namespace App\Models; use App\Notifications\Channels\SendsEmail; use App\Notifications\TransactionalEmails\ResetPassword as TransactionalEmailsResetPassword; +use Cache; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; @@ -94,7 +95,9 @@ class User extends Authenticatable implements SendsEmail public function currentTeam() { - return Team::find(session('currentTeam')->id); + return Cache::remember('team:' . auth()->user()->id, 3600, function() { + return Team::find(session('currentTeam')->id); + }); } public function otherTeams() diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 161675301..7a8c5429b 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -57,9 +57,15 @@ function showBoarding(): bool { return currentTeam()->show_boarding ?? false; } -function refreshSession(): void +function refreshSession(?Team $team = null): void { - $team = Team::find(currentTeam()->id); + if (!$team) { + $team = Team::find(currentTeam()->id); + } + Cache::forget('team:' . auth()->user()->id); + Cache::remember('team:' . auth()->user()->id, 3600, function() use ($team) { + return $team; + }); session(['currentTeam' => $team]); } function general_error_handler(Throwable | null $err = null, $that = null, $isJson = false, $customErrorMessage = null): mixed From 929a4e647423fac18c6aefedb792562b743d3a02 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 8 Sep 2023 18:40:25 +0200 Subject: [PATCH 11/12] fix: coolify already exists should not throw error --- app/Actions/Server/InstallDocker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Actions/Server/InstallDocker.php b/app/Actions/Server/InstallDocker.php index a85981c6b..78254cc4c 100644 --- a/app/Actions/Server/InstallDocker.php +++ b/app/Actions/Server/InstallDocker.php @@ -40,7 +40,7 @@ class InstallDocker "echo ####### Restarting Docker Engine...", "systemctl restart docker", "echo ####### Creating default network...", - "docker network create --attachable coolify", + "docker network create --attachable coolify >/dev/null 2>&1 || true", "echo ####### Done!" ], $server); $found = StandaloneDocker::where('server_id', $server->id); From 53b15a5762ec1379f188fb7b86a5d4f9cc0eb974 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 8 Sep 2023 18:40:32 +0200 Subject: [PATCH 12/12] update sentry dsn --- config/sentry.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/sentry.php b/config/sentry.php index 38749f3a4..86a4adee0 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -3,7 +3,7 @@ return [ // @see https://docs.sentry.io/product/sentry-basics/dsn-explainer/ - 'dsn' => 'https://abe219b6573947128ecf523c835f5f38@o1082494.ingest.sentry.io/4505347448045568', + 'dsn' => 'https://62de992090e4e0cb28f18231835ea006@o1082494.ingest.sentry.io/4505347448045568', // The release version of your application // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))