From 231c02e00e196a72a346fcea73565d6707e0bfa9 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 1 Sep 2023 16:16:35 +0200 Subject: [PATCH 01/38] 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 f0ce8e18d..7b993b0d9 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.23', + 'release' => '4.0.0-beta.24', '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 a0d53aeca..54f276a01 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ Date: Fri, 1 Sep 2023 16:30:50 +0200 Subject: [PATCH 02/38] Do not schedule autoupdate --- app/Console/Kernel.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 07032e1a1..7e0bbf580 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -9,6 +9,7 @@ use App\Jobs\DockerCleanupJob; use App\Jobs\InstanceAutoUpdateJob; use App\Jobs\ProxyCheckJob; use App\Jobs\ResourceStatusJob; +use App\Models\InstanceSettings; use App\Models\ScheduledDatabaseBackup; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; @@ -17,28 +18,33 @@ class Kernel extends ConsoleKernel { protected function schedule(Schedule $schedule): void { - // $schedule->call(fn() => $this->check_scheduled_backups($schedule))->everyTenSeconds(); if (isDev()) { $schedule->command('horizon:snapshot')->everyMinute(); $schedule->job(new ResourceStatusJob)->everyMinute(); $schedule->job(new ProxyCheckJob)->everyFiveMinutes(); $schedule->job(new CleanupInstanceStuffsJob)->everyMinute(); - // $schedule->job(new CheckResaleLicenseJob)->hourly(); $schedule->job(new DockerCleanupJob)->everyOddHour(); - // $schedule->job(new InstanceAutoUpdateJob(true))->everyMinute(); } else { $schedule->command('horizon:snapshot')->everyFiveMinutes(); - $schedule->job(new CleanupInstanceStuffsJob)->everyMinute()->onOneServer(); + $schedule->job(new CleanupInstanceStuffsJob)->everyTenMinutes()->onOneServer(); $schedule->job(new ResourceStatusJob)->everyMinute()->onOneServer(); $schedule->job(new CheckResaleLicenseJob)->hourly()->onOneServer(); $schedule->job(new ProxyCheckJob)->everyFiveMinutes()->onOneServer(); $schedule->job(new DockerCleanupJob)->everyTenMinutes()->onOneServer(); - $schedule->job(new InstanceAutoUpdateJob)->everyTenMinutes(); } + $this->instance_auto_update($schedule); $this->check_scheduled_backups($schedule); } - + private function instance_auto_update($schedule){ + if (isDev()) { + return; + } + $settings = InstanceSettings::get(); + if ($settings->is_auto_update_enabled) { + $schedule->job(new InstanceAutoUpdateJob)->everyTenMinutes()->onOneServer(); + } + } private function check_scheduled_backups($schedule) { ray('check_scheduled_backups'); @@ -57,7 +63,7 @@ class Kernel extends ConsoleKernel } $schedule->job(new DatabaseBackupJob( backup: $scheduled_backup - ))->cron($scheduled_backup->frequency); + ))->cron($scheduled_backup->frequency)->onOneServer(); } } From 0065a8637197bd232e6d7b35b8bbeadb7e747120 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 1 Sep 2023 16:36:41 +0200 Subject: [PATCH 03/38] update seeder --- database/seeders/ProductionSeeder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/seeders/ProductionSeeder.php b/database/seeders/ProductionSeeder.php index 8b6ee3141..9a307c7eb 100644 --- a/database/seeders/ProductionSeeder.php +++ b/database/seeders/ProductionSeeder.php @@ -45,7 +45,7 @@ class ProductionSeeder extends Seeder ]); } - if (config('app.name') !== 'coolify-cloud') { + if (config('app.name') !== 'Coolify Cloud') { // Save SSH Keys for the Coolify Host $coolify_key_name = "id.root@host.docker.internal"; $coolify_key = Storage::disk('ssh-keys')->get("{$coolify_key_name}"); From 135a29808031aaa1703978c2289be28e11008459 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sat, 2 Sep 2023 13:27:03 +0200 Subject: [PATCH 04/38] remove line --- app/Http/Controllers/ProjectController.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 07e4a2a0f..579a6b167 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -60,9 +60,6 @@ class ProjectController extends Controller 'environment_name' => $environment->name, 'database_uuid' => $standalone_postgresql->uuid, ]); - } - if ($server) { - } return view('project.new', [ 'type' => $type From eac78340838478fe97313415bfedfe9779978d6a Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sat, 2 Sep 2023 13:39:44 +0200 Subject: [PATCH 05/38] fix: form address --- app/Notifications/Channels/EmailChannel.php | 26 ++------------------- bootstrap/helpers/shared.php | 2 ++ 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/app/Notifications/Channels/EmailChannel.php b/app/Notifications/Channels/EmailChannel.php index 0c042fcfc..e0f9edac0 100644 --- a/app/Notifications/Channels/EmailChannel.php +++ b/app/Notifications/Channels/EmailChannel.php @@ -9,7 +9,6 @@ use Illuminate\Support\Facades\Mail; class EmailChannel { - private bool $isResend = false; public function send(SendsEmail $notifiable, Notification $notification): void { $this->bootConfigs($notifiable); @@ -20,33 +19,14 @@ class EmailChannel } $mailMessage = $notification->toMail($notifiable); - // if ($this->isResend) { Mail::send( [], [], fn (Message $message) => $message - ->from( - data_get($notifiable, 'smtp_from_address'), - data_get($notifiable, 'smtp_from_name'), - ) ->to($recepients) ->subject($mailMessage->subject) ->html((string)$mailMessage->render()) ); - // } else { - // Mail::send( - // [], - // [], - // fn (Message $message) => $message - // ->from( - // data_get($notifiable, 'smtp_from_address'), - // data_get($notifiable, 'smtp_from_name'), - // ) - // ->bcc($recepients) - // ->subject($mailMessage->subject) - // ->html((string)$mailMessage->render()) - // ); - // } } private function bootConfigs($notifiable): void @@ -56,13 +36,11 @@ class EmailChannel if (!$type) { throw new Exception('No email settings found.'); } - if ($type === 'resend') { - $this->isResend = true; - } return; } + config()->set('mail.from.address', data_get($notifiable, 'smtp_from_address')); + config()->set('mail.from.name', data_get($notifiable, 'smtp_from_name')); if (data_get($notifiable, 'resend_enabled')) { - $this->isResend = true; config()->set('mail.default', 'resend'); config()->set('resend.api_key', data_get($notifiable, 'resend_api_key')); } diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 249f76920..7056b159b 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -149,6 +149,8 @@ function set_transanctional_email_settings(InstanceSettings | null $settings = n if (!$settings) { $settings = InstanceSettings::get(); } + config()->set('mail.from.address', data_get($settings, 'smtp_from_address')); + config()->set('mail.from.name', data_get($settings, 'smtp_from_name')); if (data_get($settings, 'resend_enabled')) { config()->set('mail.default', 'resend'); config()->set('resend.api_key', data_get($settings, 'resend_api_key')); From 040f47b59c43d6c6de4b4ab4281d7d9b16a086f3 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sat, 2 Sep 2023 13:41:42 +0200 Subject: [PATCH 06/38] fix: show hosted email service, just disable for non pro subs --- .../views/livewire/notifications/email-settings.blade.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/resources/views/livewire/notifications/email-settings.blade.php b/resources/views/livewire/notifications/email-settings.blade.php index 1185ad290..92ed83fd8 100644 --- a/resources/views/livewire/notifications/email-settings.blade.php +++ b/resources/views/livewire/notifications/email-settings.blade.php @@ -35,7 +35,13 @@ + @else +
+ +
@endif +

Custom Email Service

@if (!$team->use_instance_email_settings)
From 6b9c7aa9c56bc480107d6e59854075b96ee80907 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sat, 2 Sep 2023 15:37:25 +0200 Subject: [PATCH 07/38] feat: send request in cloud --- app/Http/Livewire/Help.php | 54 +++++++++++++++++++ .../Channels/TransactionalEmailChannel.php | 23 -------- bootstrap/helpers/shared.php | 6 --- bootstrap/helpers/subscriptions.php | 3 ++ resources/views/components/modal.blade.php | 4 -- resources/views/components/navbar.blade.php | 14 +++++ resources/views/emails/help.blade.php | 5 ++ resources/views/layouts/base.blade.php | 8 +++ resources/views/livewire/help.blade.php | 10 ++++ routes/web.php | 2 + 10 files changed, 96 insertions(+), 33 deletions(-) create mode 100644 app/Http/Livewire/Help.php create mode 100644 resources/views/emails/help.blade.php create mode 100644 resources/views/livewire/help.blade.php diff --git a/app/Http/Livewire/Help.php b/app/Http/Livewire/Help.php new file mode 100644 index 000000000..107821501 --- /dev/null +++ b/app/Http/Livewire/Help.php @@ -0,0 +1,54 @@ + 'required|min:10', + 'subject' => 'required|min:3' + ]; + public function mount() + { + $this->path = Route::current()->uri(); + if (isDev()) { + $this->description = "I'm having trouble with {$this->path}"; + $this->subject = "Help with {$this->path}"; + } + } + public function submit() + { + try { + $this->rateLimit(1, 60); + $this->validate(); + $subscriptionType = auth()->user()?->subscription?->type() ?? 'unknown'; + $debug = "Route: {$this->path}"; + $mail = new MailMessage(); + $mail->view( + 'emails.help', + [ + 'description' => $this->description, + 'debug' => $debug + ] + ); + $mail->subject("[HELP - {$subscriptionType}]: {$this->subject}"); + send_user_an_email($mail, 'hi@coollabs.io'); + $this->emit('success', 'Your message has been sent successfully. We will get in touch with you as soon as possible.'); + } catch (\Exception $e) { + return general_error_handler($e, $this); + } + } + public function render() + { + return view('livewire.help')->layout('layouts.app'); + } +} diff --git a/app/Notifications/Channels/TransactionalEmailChannel.php b/app/Notifications/Channels/TransactionalEmailChannel.php index aa5541dee..2985d5183 100644 --- a/app/Notifications/Channels/TransactionalEmailChannel.php +++ b/app/Notifications/Channels/TransactionalEmailChannel.php @@ -12,7 +12,6 @@ use Log; class TransactionalEmailChannel { - private bool $isResend = false; public function send(User $notifiable, Notification $notification): void { $settings = InstanceSettings::get(); @@ -26,33 +25,14 @@ class TransactionalEmailChannel } $this->bootConfigs(); $mailMessage = $notification->toMail($notifiable); - // if ($this->isResend) { Mail::send( [], [], fn (Message $message) => $message - ->from( - data_get($settings, 'smtp_from_address'), - data_get($settings, 'smtp_from_name'), - ) ->to($email) ->subject($mailMessage->subject) ->html((string)$mailMessage->render()) ); - // } else { - // Mail::send( - // [], - // [], - // fn (Message $message) => $message - // ->from( - // data_get($settings, 'smtp_from_address'), - // data_get($settings, 'smtp_from_name'), - // ) - // ->bcc($email) - // ->subject($mailMessage->subject) - // ->html((string)$mailMessage->render()) - // ); - // } } private function bootConfigs(): void @@ -61,8 +41,5 @@ class TransactionalEmailChannel if (!$type) { throw new Exception('No email settings found.'); } - if ($type === 'resend') { - $this->isResend = true; - } } } diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 7056b159b..e45dfa08a 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -7,7 +7,6 @@ use DanHarrin\LivewireRateLimiting\Exceptions\TooManyRequestsException; use Illuminate\Database\QueryException; use Illuminate\Mail\Message; use Illuminate\Notifications\Messages\MailMessage; -use Illuminate\Support\Collection; use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Route; @@ -261,15 +260,10 @@ function send_user_an_email(MailMessage $mail, string $email): void [], [], fn (Message $message) => $message - ->from( - data_get($settings, 'smtp_from_address'), - data_get($settings, 'smtp_from_name') - ) ->to($email) ->subject($mail->subject) ->html((string) $mail->render()) ); - } function isEmailEnabled($notifiable) { diff --git a/bootstrap/helpers/subscriptions.php b/bootstrap/helpers/subscriptions.php index 7691ca7d6..ae3506782 100644 --- a/bootstrap/helpers/subscriptions.php +++ b/bootstrap/helpers/subscriptions.php @@ -47,6 +47,9 @@ function getEndDate() function isSubscriptionActive() { + if (!isCloud()) { + return false; + } $team = currentTeam(); if (!$team) { return false; diff --git a/resources/views/components/modal.blade.php b/resources/views/components/modal.blade.php index 711515437..d31dc542a 100644 --- a/resources/views/components/modal.blade.php +++ b/resources/views/components/modal.blade.php @@ -43,10 +43,6 @@ @endisset @if ($modalSubmit) {{ $modalSubmit }} - @else - - Save - @endif diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php index 6fd4b218a..65cbc482b 100644 --- a/resources/views/components/navbar.blade.php +++ b/resources/views/components/navbar.blade.php @@ -95,6 +95,20 @@ @endif + @if (isSubscriptionActive() || isDev()) +
  • +
    + + + + + + +
    +
  • + @endif
  • @csrf diff --git a/resources/views/emails/help.blade.php b/resources/views/emails/help.blade.php new file mode 100644 index 000000000..a9f8aeb69 --- /dev/null +++ b/resources/views/emails/help.blade.php @@ -0,0 +1,5 @@ +{{ $description }} + +{{ Illuminate\Mail\Markdown::parse('---') }} + +{{ Illuminate\Mail\Markdown::parse($debug) }} diff --git a/resources/views/layouts/base.blade.php b/resources/views/layouts/base.blade.php index 6302eddeb..6c69eecc3 100644 --- a/resources/views/layouts/base.blade.php +++ b/resources/views/layouts/base.blade.php @@ -25,6 +25,14 @@ @livewireScripts + @if (isSubscriptionActive() || isDev()) + + + + + +
    + @endif