diff --git a/app/Data/SmtpConfiguration.php b/app/Data/SmtpConfiguration.php deleted file mode 100644 index ce290f88c..000000000 --- a/app/Data/SmtpConfiguration.php +++ /dev/null @@ -1,23 +0,0 @@ - 'nullable|boolean', - 'model.extra_attributes.discord_webhook_url' => 'required|url', - 'model.extra_attributes.notifications_discord_test' => 'nullable|boolean', - 'model.extra_attributes.notifications_discord_deployments' => 'nullable|boolean', + 'model.discord.enabled' => 'nullable|boolean', + 'model.discord.webhook_url' => 'required|url', + 'model.discord_notifications.test' => 'nullable|boolean', + 'model.discord_notifications.deployments' => 'nullable|boolean', + ]; protected $validationAttributes = [ - 'model.extra_attributes.discord_webhook_url' => 'Discord Webhook', + 'model.discord.webhook_url' => 'Discord Webhook', ]; public function instantSave() { try { $this->submit(); } catch (\Exception $e) { - $this->model->extra_attributes->discord_enabled = false; + $this->model->discord->enabled = false; $this->validate(); } } diff --git a/app/Http/Livewire/Notifications/EmailSettings.php b/app/Http/Livewire/Notifications/EmailSettings.php index d928cd517..88004bea5 100644 --- a/app/Http/Livewire/Notifications/EmailSettings.php +++ b/app/Http/Livewire/Notifications/EmailSettings.php @@ -12,53 +12,55 @@ class EmailSettings extends Component public Team $model; protected $rules = [ - 'model.extra_attributes.smtp_enabled' => 'nullable|boolean', - 'model.extra_attributes.smtp_from_address' => 'required|email', - 'model.extra_attributes.smtp_from_name' => 'required', - 'model.extra_attributes.smtp_recipients' => 'nullable', - 'model.extra_attributes.smtp_host' => 'required', - 'model.extra_attributes.smtp_port' => 'required', - 'model.extra_attributes.smtp_encryption' => 'nullable', - 'model.extra_attributes.smtp_username' => 'nullable', - 'model.extra_attributes.smtp_password' => 'nullable', - 'model.extra_attributes.smtp_timeout' => 'nullable', - 'model.extra_attributes.smtp_test_recipients' => 'nullable', - 'model.extra_attributes.notifications_smtp_test' => 'nullable|boolean', - 'model.extra_attributes.notifications_email_deployments' => 'nullable|boolean', + 'model.smtp.enabled' => 'nullable|boolean', + 'model.smtp.from_address' => 'required|email', + 'model.smtp.from_name' => 'required', + 'model.smtp.recipients' => 'nullable', + 'model.smtp.host' => 'required', + 'model.smtp.port' => 'required', + 'model.smtp.encryption' => 'nullable', + 'model.smtp.username' => 'nullable', + 'model.smtp.password' => 'nullable', + 'model.smtp.timeout' => 'nullable', + 'model.smtp.test_recipients' => 'nullable', + 'model.smtp_notifications.test' => 'nullable|boolean', + 'model.smtp_notifications.deployments' => 'nullable|boolean', + 'model.discord_notifications.test' => 'nullable|boolean', + 'model.discord_notifications.deployments' => 'nullable|boolean', ]; protected $validationAttributes = [ - 'model.extra_attributes.smtp_from_address' => 'From Address', - 'model.extra_attributes.smtp_from_name' => 'From Name', - 'model.extra_attributes.smtp_recipients' => 'Recipients', - 'model.extra_attributes.smtp_host' => 'Host', - 'model.extra_attributes.smtp_port' => 'Port', - 'model.extra_attributes.smtp_encryption' => 'Encryption', - 'model.extra_attributes.smtp_username' => 'Username', - 'model.extra_attributes.smtp_password' => 'Password', - 'model.extra_attributes.smtp_test_recipients' => 'Test Recipients', + 'model.smtp.from_address' => 'From Address', + 'model.smtp.from_name' => 'From Name', + 'model.smtp.recipients' => 'Recipients', + 'model.smtp.host' => 'Host', + 'model.smtp.port' => 'Port', + 'model.smtp.encryption' => 'Encryption', + 'model.smtp.username' => 'Username', + 'model.smtp.password' => 'Password', + 'model.smtp.test_recipients' => 'Test Recipients', ]; - public function copySMTP() + public function copyFromInstanceSettings() { $settings = InstanceSettings::get(); - $this->model->extra_attributes->smtp_enabled = true; - $this->model->extra_attributes->smtp_from_address = $settings->extra_attributes->smtp_from_address; - $this->model->extra_attributes->smtp_from_name = $settings->extra_attributes->smtp_from_name; - $this->model->extra_attributes->smtp_recipients = $settings->extra_attributes->smtp_recipients; - $this->model->extra_attributes->smtp_host = $settings->extra_attributes->smtp_host; - $this->model->extra_attributes->smtp_port = $settings->extra_attributes->smtp_port; - $this->model->extra_attributes->smtp_encryption = $settings->extra_attributes->smtp_encryption; - $this->model->extra_attributes->smtp_username = $settings->extra_attributes->smtp_username; - $this->model->extra_attributes->smtp_password = $settings->extra_attributes->smtp_password; - $this->model->extra_attributes->smtp_timeout = $settings->extra_attributes->smtp_timeout; - $this->model->extra_attributes->smtp_test_recipients = $settings->extra_attributes->smtp_test_recipients; + $this->model->smtp->enabled = true; + $this->model->smtp->from_address = $settings->smtp->from_address; + $this->model->smtp->from_name = $settings->smtp->from_name; + $this->model->smtp->recipients = $settings->smtp->recipients; + $this->model->smtp->host = $settings->smtp->host; + $this->model->smtp->port = $settings->smtp->port; + $this->model->smtp->encryption = $settings->smtp->encryption; + $this->model->smtp->username = $settings->smtp->username; + $this->model->smtp->password = $settings->smtp->password; + $this->model->smtp->timeout = $settings->smtp->timeout; + $this->model->smtp->test_recipients = $settings->smtp->test_recipients; $this->saveModel(); } public function submit() { $this->resetErrorBag(); $this->validate(); - $this->model->extra_attributes->smtp_recipients = str_replace(' ', '', $this->model->extra_attributes->smtp_recipients); - $this->model->extra_attributes->smtp_test_recipients = str_replace(' ', '', $this->model->extra_attributes->smtp_test_recipients); + $this->model->smtp->recipients = str_replace(' ', '', $this->model->smtp->recipients); + $this->model->smtp->test_recipients = str_replace(' ', '', $this->model->smtp->test_recipients); $this->saveModel(); } public function saveModel() @@ -79,7 +81,7 @@ class EmailSettings extends Component try { $this->submit(); } catch (\Exception $e) { - $this->model->extra_attributes->smtp_enabled = false; + $this->model->smtp->enabled = false; $this->validate(); } } diff --git a/app/Http/Livewire/Settings/Email.php b/app/Http/Livewire/Settings/Email.php index 75f10e6e9..e15c9e5d6 100644 --- a/app/Http/Livewire/Settings/Email.php +++ b/app/Http/Livewire/Settings/Email.php @@ -12,34 +12,34 @@ class Email extends Component public InstanceSettings $settings; protected $rules = [ - 'settings.extra_attributes.smtp_enabled' => 'nullable|boolean', - 'settings.extra_attributes.smtp_host' => 'required', - 'settings.extra_attributes.smtp_port' => 'required|numeric', - 'settings.extra_attributes.smtp_encryption' => 'nullable', - 'settings.extra_attributes.smtp_username' => 'nullable', - 'settings.extra_attributes.smtp_password' => 'nullable', - 'settings.extra_attributes.smtp_timeout' => 'nullable', - 'settings.extra_attributes.smtp_test_recipients' => 'nullable', - 'settings.extra_attributes.smtp_from_address' => 'required|email', - 'settings.extra_attributes.smtp_from_name' => 'required', + 'settings.smtp.enabled' => 'nullable|boolean', + 'settings.smtp.host' => 'required', + 'settings.smtp.port' => 'required|numeric', + 'settings.smtp.encryption' => 'nullable', + 'settings.smtp.username' => 'nullable', + 'settings.smtp.password' => 'nullable', + 'settings.smtp.timeout' => 'nullable', + 'settings.smtp.test_recipients' => 'nullable', + 'settings.smtp.from_address' => 'required|email', + 'settings.smtp.from_name' => 'required', ]; protected $validationAttributes = [ - 'settings.extra_attributes.smtp_from_address' => 'From Address', - 'settings.extra_attributes.smtp_from_name' => 'From Name', - 'settings.extra_attributes.smtp_recipients' => 'Recipients', - 'settings.extra_attributes.smtp_host' => 'Host', - 'settings.extra_attributes.smtp_port' => 'Port', - 'settings.extra_attributes.smtp_encryption' => 'Encryption', - 'settings.extra_attributes.smtp_username' => 'Username', - 'settings.extra_attributes.smtp_password' => 'Password', - 'settings.extra_attributes.smtp_test_recipients' => 'Test Recipients', + 'settings.smtp.from_address' => 'From Address', + 'settings.smtp.from_name' => 'From Name', + 'settings.smtp.recipients' => 'Recipients', + 'settings.smtp.host' => 'Host', + 'settings.smtp.port' => 'Port', + 'settings.smtp.encryption' => 'Encryption', + 'settings.smtp.username' => 'Username', + 'settings.smtp.password' => 'Password', + 'settings.smtp.test_recipients' => 'Test Recipients', ]; public function instantSave() { try { $this->submit(); } catch (\Exception $e) { - $this->settings->extra_attributes->smtp_enabled = false; + $this->settings->smtp->enabled = false; $this->validate(); } } @@ -51,7 +51,7 @@ class Email extends Component public function submit() { $this->validate(); - $this->settings->extra_attributes->smtp_test_recipients = str_replace(' ', '', $this->settings->extra_attributes->smtp_test_recipients); + $this->settings->smtp->test_recipients = str_replace(' ', '', $this->settings->smtp->test_recipients); $this->settings->save(); } } diff --git a/app/Models/InstanceSettings.php b/app/Models/InstanceSettings.php index cc66facd4..fefd315ce 100644 --- a/app/Models/InstanceSettings.php +++ b/app/Models/InstanceSettings.php @@ -7,20 +7,24 @@ use Illuminate\Contracts\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Notifications\Notifiable; use Spatie\SchemalessAttributes\Casts\SchemalessAttributes; +use Spatie\SchemalessAttributes\SchemalessAttributesTrait; class InstanceSettings extends Model implements SendsEmail { - use Notifiable; - protected $casts = [ - 'extra_attributes' => SchemalessAttributes::class, + use Notifiable, SchemalessAttributesTrait; + protected $schemalessAttributes = [ + 'smtp', ]; - public function scopeWithExtraAttributes(): Builder + protected $casts = [ + 'smtp' => SchemalessAttributes::class, + ]; + public function scopeWithSmtp(): Builder { - return $this->extra_attributes->modelScope(); + return $this->smtp->modelScope(); } - public function routeNotificationForEmail(string $attribute = 'smtp_test_recipients') + public function routeNotificationForEmail(string $attribute = 'test_recipients') { - $recipients = $this->extra_attributes->get($attribute, ''); + $recipients = $this->smtp->get($attribute, ''); if (is_null($recipients) || $recipients === '') { return []; } diff --git a/app/Models/Team.php b/app/Models/Team.php index 42342aebd..cf9a1f5cb 100644 --- a/app/Models/Team.php +++ b/app/Models/Team.php @@ -8,40 +8,64 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Notifications\Notifiable; use Spatie\SchemalessAttributes\Casts\SchemalessAttributes; +use Spatie\SchemalessAttributes\SchemalessAttributesTrait; class Team extends Model implements SendsDiscord, SendsEmail { - use Notifiable; + use Notifiable, SchemalessAttributesTrait; + protected $schemalessAttributes = [ + 'smtp', + 'discord', + 'smtp_notifications', + 'discord_notifications', + ]; protected $casts = [ - 'extra_attributes' => SchemalessAttributes::class, + 'smtp' => SchemalessAttributes::class, + 'discord' => SchemalessAttributes::class, + 'smtp_notifications' => SchemalessAttributes::class, + 'discord_notifications' => SchemalessAttributes::class, 'personal_team' => 'boolean', ]; + public function scopeWithSmtp(): Builder + { + return $this->smtp->modelScope(); + } + public function scopeWithDiscord(): Builder + { + return $this->discord->modelScope(); + } + public function scopeWithSmtpNotifications(): Builder + { + return $this->smtp_notifications->modelScope(); + } + public function scopeWithDiscordNotifications(): Builder + { + return $this->discord_notifications->modelScope(); + } protected $fillable = [ 'id', 'name', 'description', 'personal_team', - 'extra_attributes', + 'smtp', + 'discord' ]; public function routeNotificationForDiscord() { - return $this->extra_attributes->get('discord_webhook_url'); + return $this->discord->get('webhook_url'); } - public function routeNotificationForEmail(string $attribute = 'smtp_recipients') + public function routeNotificationForEmail(string $attribute = 'recipients') { - $recipients = $this->extra_attributes->get($attribute, ''); + $recipients = $this->smtp->get($attribute, ''); if (is_null($recipients) || $recipients === '') { return []; } return explode(',', $recipients); } - public function scopeWithExtraAttributes(): Builder - { - return $this->extra_attributes->modelScope(); - } + public function projects() { diff --git a/app/Models/User.php b/app/Models/User.php index 2e5148d48..da42a977f 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -34,10 +34,20 @@ class User extends Authenticatable implements SendsEmail $team = [ 'name' => $user->name . "'s Team", 'personal_team' => true, - 'extra_attributes' => [ - 'notifications_smtp_test' => true, - 'notifications_discord_test' => true, - ] + 'smtp' => [ + 'enabled' => false, + ], + 'smtp_notifications' => [ + 'test' => true, + 'deployments' => false, + ], + 'discord' => [ + 'enabled' => false, + ], + 'discord_notifications' => [ + 'test' => true, + 'deployments' => false, + ], ]; if ($user->id === 0) { $team['id'] = 0; diff --git a/app/Notifications/Channels/EmailChannel.php b/app/Notifications/Channels/EmailChannel.php index 8db504f40..bc5c7e46e 100644 --- a/app/Notifications/Channels/EmailChannel.php +++ b/app/Notifications/Channels/EmailChannel.php @@ -12,7 +12,7 @@ class EmailChannel { $this->bootConfigs($notifiable); - $bcc = $notifiable->routeNotificationForEmail('smtp_test_recipients'); + $bcc = $notifiable->routeNotificationForEmail('test_recipients'); if (count($bcc) === 0) { if ($notifiable instanceof \App\Models\Team) { $bcc = $notifiable->members()->pluck('email')->toArray(); @@ -24,8 +24,8 @@ class EmailChannel [], fn (Message $message) => $message ->from( - $notifiable->extra_attributes?->get('smtp_from_address'), - $notifiable->extra_attributes?->get('smtp_from_name') + data_get($notifiable, 'smtp.from_address'), + data_get($notifiable, 'smtp.from_name'), ) ->bcc($bcc) ->subject($mailMessage->subject) @@ -38,12 +38,12 @@ class EmailChannel config()->set('mail.default', 'smtp'); config()->set('mail.mailers.smtp', [ "transport" => "smtp", - "host" => $notifiable->extra_attributes?->get('smtp_host'), - "port" => $notifiable->extra_attributes?->get('smtp_port'), - "encryption" => $notifiable->extra_attributes?->get('smtp_encryption'), - "username" => $notifiable->extra_attributes?->get('smtp_username'), - "password" => $notifiable->extra_attributes?->get('smtp_password'), - "timeout" => $notifiable->extra_attributes?->get('smtp_timeout'), + "host" => data_get($notifiable, 'smtp.host'), + "port" => data_get($notifiable, 'smtp.port'), + "encryption" => data_get($notifiable, 'smtp.encryption'), + "username" => data_get($notifiable, 'smtp.username'), + "password" => data_get($notifiable, 'smtp.password'), + "timeout" => data_get($notifiable, 'smtp.timeout'), "local_domain" => null, ]); } diff --git a/app/Notifications/Channels/TransactionalEmailChannel.php b/app/Notifications/Channels/TransactionalEmailChannel.php index d4098f0da..431469e10 100644 --- a/app/Notifications/Channels/TransactionalEmailChannel.php +++ b/app/Notifications/Channels/TransactionalEmailChannel.php @@ -13,23 +13,22 @@ class TransactionalEmailChannel public function send(User $notifiable, Notification $notification): void { $settings = InstanceSettings::get(); - if ($settings->extra_attributes?->get('smtp_enabled') !== true) { + if (data_get($settings, 'smtp.enabled') !== true) { return; } $email = $notifiable->email; if (!$email) { return; } - $this->bootConfigs($settings); + $this->bootConfigs(); $mailMessage = $notification->toMail($notifiable); - Mail::send( [], [], fn (Message $message) => $message ->from( - $settings->extra_attributes?->get('smtp_from_address'), - $settings->extra_attributes?->get('smtp_from_name') + data_get($settings, 'smtp.from_address'), + data_get($settings, 'smtp.from_name') ) ->to($email) ->subject($mailMessage->subject) @@ -37,7 +36,7 @@ class TransactionalEmailChannel ); } - private function bootConfigs(InstanceSettings $settings): void + private function bootConfigs(): void { set_transanctional_email_settings(); } diff --git a/app/Notifications/Notifications/Application/DeployedSuccessfullyNotification.php b/app/Notifications/Notifications/Application/DeployedSuccessfullyNotification.php index a13ad7901..22f0badc7 100644 --- a/app/Notifications/Notifications/Application/DeployedSuccessfullyNotification.php +++ b/app/Notifications/Notifications/Application/DeployedSuccessfullyNotification.php @@ -43,10 +43,15 @@ class DeployedSuccessfullyNotification extends Notification implements ShouldQue public function via(object $notifiable): array { $channels = []; - if ($notifiable->extra_attributes?->get('smtp_enabled') && $notifiable->extra_attributes?->get('notifications_email_deployments')) { + $isEmailEnabled = data_get($notifiable, 'smtp.enabled'); + $isDiscordEnabled = data_get($notifiable, 'discord.enabled'); + $isSubscribedToEmailDeployments = data_get($notifiable, 'smtp_notifications.deployments'); + $isSubscribedToDiscordDeployments = data_get($notifiable, 'discord_notifications.deployments'); + + if ($isEmailEnabled && $isSubscribedToEmailDeployments) { $channels[] = EmailChannel::class; } - if ($notifiable->extra_attributes?->get('discord_enabled') && $notifiable->extra_attributes?->get('notifications_discord_deployments')) { + if ($isDiscordEnabled && $isSubscribedToDiscordDeployments) { $channels[] = DiscordChannel::class; } return $channels; diff --git a/app/Notifications/Notifications/Application/DeployedWithErrorNotification.php b/app/Notifications/Notifications/Application/DeployedWithErrorNotification.php index ecbc97359..2e309024d 100644 --- a/app/Notifications/Notifications/Application/DeployedWithErrorNotification.php +++ b/app/Notifications/Notifications/Application/DeployedWithErrorNotification.php @@ -44,10 +44,15 @@ class DeployedWithErrorNotification extends Notification implements ShouldQueue public function via(object $notifiable): array { $channels = []; - if ($notifiable->extra_attributes?->get('smtp_enabled') && $notifiable->extra_attributes?->get('notifications_email_deployments')) { + $isEmailEnabled = data_get($notifiable, 'smtp.enabled'); + $isDiscordEnabled = data_get($notifiable, 'discord.enabled'); + $isSubscribedToEmailDeployments = data_get($notifiable, 'smtp_notifications.deployments'); + $isSubscribedToDiscordDeployments = data_get($notifiable, 'discord_notifications.deployments'); + + if ($isEmailEnabled && $isSubscribedToEmailDeployments) { $channels[] = EmailChannel::class; } - if ($notifiable->extra_attributes?->get('discord_enabled') && $notifiable->extra_attributes?->get('notifications_discord_deployments')) { + if ($isDiscordEnabled && $isSubscribedToDiscordDeployments) { $channels[] = DiscordChannel::class; } return $channels; diff --git a/app/Notifications/Notifications/TestNotification.php b/app/Notifications/Notifications/TestNotification.php index 6f03c27e1..8e10e3d94 100644 --- a/app/Notifications/Notifications/TestNotification.php +++ b/app/Notifications/Notifications/TestNotification.php @@ -20,12 +20,21 @@ class TestNotification extends Notification implements ShouldQueue public function via(object $notifiable): array { $channels = []; - if (($this->type === 'smtp' || is_null($this->type)) && $notifiable->extra_attributes?->get('smtp_enabled') && $notifiable->extra_attributes?->get('notifications_smtp_test')) { + + $isSmtp = $this->type === 'smtp' || is_null($this->type); + $isDiscord = $this->type === 'discord' || is_null($this->type); + $isEmailEnabled = data_get($notifiable, 'smtp.enabled'); + $isDiscordEnabled = data_get($notifiable, 'discord.enabled'); + $isSubscribedToEmailTests = data_get($notifiable, 'smtp_notifications.test'); + $isSubscribedToDiscordTests = data_get($notifiable, 'discord_notifications.test'); + + if ($isEmailEnabled && $isSubscribedToEmailTests && $isSmtp) { $channels[] = EmailChannel::class; } - if (($this->type === 'discord' || is_null($this->type)) && $notifiable->extra_attributes?->get('discord_enabled') && $notifiable->extra_attributes?->get('notifications_discord_test')) { + if ($isDiscordEnabled && $isSubscribedToDiscordTests && $isDiscord) { $channels[] = DiscordChannel::class; } + return $channels; } public function toMail(): MailMessage @@ -39,7 +48,7 @@ class TestNotification extends Notification implements ShouldQueue public function toDiscord(): string { return 'This is a test Discord notification from Coolify. - + [Go to your dashboard](' . base_url() . ')'; } } diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index cb2338106..5d1821855 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -69,7 +69,7 @@ function generate_application_name(string $git_repository, string $git_branch) function is_transactional_emails_active() { - return data_get(InstanceSettings::get(), 'extra_attributes.smtp_enabled'); + return data_get(InstanceSettings::get(), 'smtp.enabled'); } function set_transanctional_email_settings() @@ -78,12 +78,12 @@ function set_transanctional_email_settings() config()->set('mail.default', 'smtp'); config()->set('mail.mailers.smtp', [ "transport" => "smtp", - "host" => $settings->extra_attributes?->get('smtp_host'), - "port" => $settings->extra_attributes?->get('smtp_port'), - "encryption" => $settings->extra_attributes?->get('smtp_encryption'), - "username" => $settings->extra_attributes?->get('smtp_username'), - "password" => $settings->extra_attributes?->get('smtp_password'), - "timeout" => $settings->extra_attributes?->get('smtp_timeout'), + "host" => data_get($settings, 'smtp.host'), + "port" => data_get($settings, 'smtp.port'), + "encryption" => data_get($settings, 'smtp.encryption'), + "username" => data_get($settings, 'smtp.username'), + "password" => data_get($settings, 'smtp.password'), + "timeout" => data_get($settings, 'smtp.timeout'), "local_domain" => null, ]); } diff --git a/database/migrations/2023_03_20_112811_create_teams_table.php b/database/migrations/2023_03_20_112811_create_teams_table.php index 83347563a..0f41c5e95 100644 --- a/database/migrations/2023_03_20_112811_create_teams_table.php +++ b/database/migrations/2023_03_20_112811_create_teams_table.php @@ -16,7 +16,10 @@ return new class extends Migration $table->string('name'); $table->string('description')->nullable(); $table->boolean('personal_team')->default(false); - $table->schemalessAttributes('extra_attributes'); + $table->schemalessAttributes('smtp'); + $table->schemalessAttributes('smtp_notifications'); + $table->schemalessAttributes('discord'); + $table->schemalessAttributes('discord_notifications'); $table->timestamps(); }); } diff --git a/database/migrations/2023_03_20_112814_create_instance_settings_table.php b/database/migrations/2023_03_20_112814_create_instance_settings_table.php index c0fc8a6fb..a90c740fc 100644 --- a/database/migrations/2023_03_20_112814_create_instance_settings_table.php +++ b/database/migrations/2023_03_20_112814_create_instance_settings_table.php @@ -23,7 +23,7 @@ return new class extends Migration $table->boolean('do_not_track')->default(false); $table->boolean('is_auto_update_enabled')->default(true); $table->boolean('is_registration_enabled')->default(true); - $table->schemalessAttributes('extra_attributes'); + $table->schemalessAttributes('smtp'); // $table->string('custom_dns_servers')->default('1.1.1.1,8.8.8.8'); // $table->boolean('is_dns_check_enabled')->default(true); $table->timestamps(); diff --git a/database/seeders/InstanceSettingsSeeder.php b/database/seeders/InstanceSettingsSeeder.php index 503ce62ff..12e6e2fcb 100644 --- a/database/seeders/InstanceSettingsSeeder.php +++ b/database/seeders/InstanceSettingsSeeder.php @@ -2,7 +2,6 @@ namespace Database\Seeders; -use App\Data\SmtpConfiguration; use App\Models\InstanceSettings; use Illuminate\Database\Seeder; use Illuminate\Support\Facades\Process; @@ -17,14 +16,14 @@ class InstanceSettingsSeeder extends Seeder InstanceSettings::create([ 'id' => 0, 'is_registration_enabled' => true, - 'extra_attributes' => SmtpConfiguration::from([ - 'smtp_enabled' => true, - 'smtp_test_recipients' => 'test@example.com,test2@example.com', - 'smtp_host' => 'coolify-mail', - 'smtp_port' => 1025, - 'smtp_from_address' => 'hi@localhost.com', - 'smtp_from_name' => 'Coolify', - ]) + 'smtp' => [ + 'enabled' => true, + 'test_recipients' => 'test@example.com,test2@example.com', + 'host' => 'coolify-mail', + 'port' => 1025, + 'from_address' => 'hi@localhost.com', + 'from_name' => 'Coolify', + ] ]); try { $ipv4 = Process::run('curl -4s https://ifconfig.io')->output(); diff --git a/resources/views/livewire/notifications/discord-settings.blade.php b/resources/views/livewire/notifications/discord-settings.blade.php index a037912a7..5785362d8 100644 --- a/resources/views/livewire/notifications/discord-settings.blade.php +++ b/resources/views/livewire/notifications/discord-settings.blade.php @@ -5,7 +5,7 @@ Save - @if ($model->extra_attributes->discord_enabled) + @if ($model->discord->enabled) Send Test Notifications @@ -13,20 +13,20 @@ @endif
- +
+ id="model.discord.webhook_url" label="Webhook" /> - @if (data_get($model, 'extra_attributes.discord_enabled')) + @if (data_get($model, 'discord.enabled'))

Subscribe to events

@if (isDev()) - @endif -
@endif diff --git a/resources/views/livewire/notifications/email-settings.blade.php b/resources/views/livewire/notifications/email-settings.blade.php index 9f3aa35ac..406c7ce6b 100644 --- a/resources/views/livewire/notifications/email-settings.blade.php +++ b/resources/views/livewire/notifications/email-settings.blade.php @@ -6,11 +6,11 @@ Save
@if (auth()->user()->isInstanceAdmin()) - + Copy from Instance Settings @endif - @if ($model->extra_attributes->smtp_enabled) + @if ($model->smtp->enabled) Send Test Notifications @@ -18,49 +18,44 @@ @endif
- +
- -
- - - + + +
- - + +
- +
- - + +
- @if (data_get($model, 'extra_attributes.smtp_enabled')) + @if (data_get($model, 'smtp.enabled'))

Subscribe to events

-
+
@if (isDev()) - @endif -
@endif diff --git a/resources/views/livewire/settings/email.blade.php b/resources/views/livewire/settings/email.blade.php index cefea888f..22f87f88b 100644 --- a/resources/views/livewire/settings/email.blade.php +++ b/resources/views/livewire/settings/email.blade.php @@ -8,12 +8,12 @@
SMTP settings for password resets, invitations, etc.
- +
- - @if ($settings->extra_attributes->smtp_enabled) + @if ($settings->smtp->enabled) Send Test Email @@ -21,26 +21,22 @@
- - - + + +
- - + - +
- - + +