diff --git a/app/Livewire/Notifications/Email.php b/app/Livewire/Notifications/Email.php index 83debb6ff..dc5a35d66 100644 --- a/app/Livewire/Notifications/Email.php +++ b/app/Livewire/Notifications/Email.php @@ -12,6 +12,8 @@ use Livewire\Component; class Email extends Component { + protected $listeners = ['refresh' => '$refresh']; + public Team $team; public EmailNotificationSettings $settings; @@ -141,9 +143,8 @@ class Email extends Component $this->settings->server_disk_usage_email_notifications = $this->serverDiskUsageEmailNotifications; $this->settings->server_reachable_email_notifications = $this->serverReachableEmailNotifications; $this->settings->server_unreachable_email_notifications = $this->serverUnreachableEmailNotifications; - $this->settings->save(); - refreshSession(); + } else { $this->smtpEnabled = $this->settings->smtp_enabled; $this->smtpFromAddress = $this->settings->smtp_from_address; @@ -173,7 +174,6 @@ class Email extends Component $this->serverDiskUsageEmailNotifications = $this->settings->server_disk_usage_email_notifications; $this->serverReachableEmailNotifications = $this->settings->server_reachable_email_notifications; $this->serverUnreachableEmailNotifications = $this->settings->server_unreachable_email_notifications; - } } @@ -190,7 +190,6 @@ class Email extends Component public function saveModel() { $this->syncData(true); - refreshSession(); $this->dispatch('success', 'Email notifications settings updated.'); } @@ -218,6 +217,8 @@ class Email extends Component } return handleError($e, $this); + } finally { + $this->dispatch('refresh'); } } @@ -261,7 +262,6 @@ class Email extends Component $this->settings->smtp_timeout = $this->smtpTimeout; $this->settings->save(); - refreshSession(); $this->dispatch('success', 'SMTP settings updated.'); } catch (\Throwable $e) { $this->smtpEnabled = false; @@ -297,7 +297,6 @@ class Email extends Component $this->settings->smtp_from_name = $this->smtpFromName; $this->settings->save(); - refreshSession(); $this->dispatch('success', 'Resend settings updated.'); } catch (\Throwable $e) { return handleError($e, $this); diff --git a/database/migrations/2024_12_05_212546_migrate_email_notification_settings_from_teams_table.php b/database/migrations/2024_12_05_212546_migrate_email_notification_settings_from_teams_table.php index da635d32d..f9d5ad0b4 100644 --- a/database/migrations/2024_12_05_212546_migrate_email_notification_settings_from_teams_table.php +++ b/database/migrations/2024_12_05_212546_migrate_email_notification_settings_from_teams_table.php @@ -13,35 +13,39 @@ return new class extends Migration $teams = DB::table('teams')->get(); foreach ($teams as $team) { - DB::table('email_notification_settings')->updateOrInsert( - ['team_id' => $team->id], - [ - 'smtp_enabled' => $team->smtp_enabled ?? false, - 'smtp_from_address' => Crypt::encryptString($team->smtp_from_address), - 'smtp_from_name' => Crypt::encryptString($team->smtp_from_name), - 'smtp_recipients' => Crypt::encryptString($team->smtp_recipients), - 'smtp_host' => Crypt::encryptString($team->smtp_host), - 'smtp_port' => $team->smtp_port, - 'smtp_encryption' => $team->smtp_encryption, - 'smtp_username' => Crypt::encryptString($team->smtp_username), - 'smtp_password' => $team->smtp_password, - 'smtp_timeout' => $team->smtp_timeout, + try { + DB::table('email_notification_settings')->updateOrInsert( + ['team_id' => $team->id], + [ + 'smtp_enabled' => $team->smtp_enabled ?? false, + 'smtp_from_address' => Crypt::encryptString($team->smtp_from_address), + 'smtp_from_name' => Crypt::encryptString($team->smtp_from_name), + 'smtp_recipients' => Crypt::encryptString($team->smtp_recipients), + 'smtp_host' => Crypt::encryptString($team->smtp_host), + 'smtp_port' => $team->smtp_port, + 'smtp_encryption' => $team->smtp_encryption, + 'smtp_username' => Crypt::encryptString($team->smtp_username), + 'smtp_password' => $team->smtp_password, + 'smtp_timeout' => $team->smtp_timeout, - 'use_instance_email_settings' => $team->use_instance_email_settings ?? false, + 'use_instance_email_settings' => $team->use_instance_email_settings ?? false, - 'resend_enabled' => $team->resend_enabled ?? false, - 'resend_api_key' => $team->resend_api_key, + 'resend_enabled' => $team->resend_enabled ?? false, + 'resend_api_key' => $team->resend_api_key, - 'deployment_success_email_notifications' => $team->smtp_notifications_deployments ?? false, - 'deployment_failure_email_notifications' => $team->smtp_notifications_deployments ?? true, - 'backup_success_email_notifications' => $team->smtp_notifications_database_backups ?? false, - 'backup_failure_email_notifications' => $team->smtp_notifications_database_backups ?? true, - 'scheduled_task_success_email_notifications' => $team->smtp_notifications_scheduled_tasks ?? false, - 'scheduled_task_failure_email_notifications' => $team->smtp_notifications_scheduled_tasks ?? true, - 'status_change_email_notifications' => $team->smtp_notifications_status_changes ?? false, - 'server_disk_usage_email_notifications' => $team->smtp_notifications_server_disk_usage ?? true, - ] - ); + 'deployment_success_email_notifications' => $team->smtp_notifications_deployments ?? false, + 'deployment_failure_email_notifications' => $team->smtp_notifications_deployments ?? true, + 'backup_success_email_notifications' => $team->smtp_notifications_database_backups ?? false, + 'backup_failure_email_notifications' => $team->smtp_notifications_database_backups ?? true, + 'scheduled_task_success_email_notifications' => $team->smtp_notifications_scheduled_tasks ?? false, + 'scheduled_task_failure_email_notifications' => $team->smtp_notifications_scheduled_tasks ?? true, + 'status_change_email_notifications' => $team->smtp_notifications_status_changes ?? false, + 'server_disk_usage_email_notifications' => $team->smtp_notifications_server_disk_usage ?? true, + ] + ); + } catch (Exception $e) { + \Log::error('Error migrating email notification settings from teams table: '.$e->getMessage()); + } } Schema::table('teams', function (Blueprint $table) { @@ -97,30 +101,34 @@ return new class extends Migration $settings = DB::table('email_notification_settings')->get(); foreach ($settings as $setting) { - DB::table('teams') - ->where('id', $setting->team_id) - ->update([ - 'smtp_enabled' => $setting->smtp_enabled, - 'smtp_from_address' => Crypt::decryptString($setting->smtp_from_address), - 'smtp_from_name' => Crypt::decryptString($setting->smtp_from_name), - 'smtp_recipients' => Crypt::decryptString($setting->smtp_recipients), - 'smtp_host' => Crypt::decryptString($setting->smtp_host), - 'smtp_port' => $setting->smtp_port, - 'smtp_encryption' => $setting->smtp_encryption, - 'smtp_username' => Crypt::decryptString($setting->smtp_username), - 'smtp_password' => $setting->smtp_password, - 'smtp_timeout' => $setting->smtp_timeout, + try { + DB::table('teams') + ->where('id', $setting->team_id) + ->update([ + 'smtp_enabled' => $setting->smtp_enabled, + 'smtp_from_address' => $setting->smtp_from_address ? Crypt::decryptString($setting->smtp_from_address) : null, + 'smtp_from_name' => $setting->smtp_from_name ? Crypt::decryptString($setting->smtp_from_name) : null, + 'smtp_recipients' => $setting->smtp_recipients ? Crypt::decryptString($setting->smtp_recipients) : null, + 'smtp_host' => $setting->smtp_host ? Crypt::decryptString($setting->smtp_host) : null, + 'smtp_port' => $setting->smtp_port, + 'smtp_encryption' => $setting->smtp_encryption, + 'smtp_username' => $setting->smtp_username ? Crypt::decryptString($setting->smtp_username) : null, + 'smtp_password' => $setting->smtp_password, + 'smtp_timeout' => $setting->smtp_timeout, - 'use_instance_email_settings' => $setting->use_instance_email_settings, + 'use_instance_email_settings' => $setting->use_instance_email_settings, - 'resend_enabled' => $setting->resend_enabled, - 'resend_api_key' => $setting->resend_api_key, + 'resend_enabled' => $setting->resend_enabled, + 'resend_api_key' => $setting->resend_api_key, - 'smtp_notifications_deployments' => $setting->deployment_success_email_notifications || $setting->deployment_failure_email_notifications, - 'smtp_notifications_database_backups' => $setting->backup_success_email_notifications || $setting->backup_failure_email_notifications, - 'smtp_notifications_scheduled_tasks' => $setting->scheduled_task_success_email_notifications || $setting->scheduled_task_failure_email_notifications, - 'smtp_notifications_status_changes' => $setting->status_change_email_notifications, - ]); + 'smtp_notifications_deployments' => $setting->deployment_success_email_notifications || $setting->deployment_failure_email_notifications, + 'smtp_notifications_database_backups' => $setting->backup_success_email_notifications || $setting->backup_failure_email_notifications, + 'smtp_notifications_scheduled_tasks' => $setting->scheduled_task_success_email_notifications || $setting->scheduled_task_failure_email_notifications, + 'smtp_notifications_status_changes' => $setting->status_change_email_notifications, + ]); + } catch (Exception $e) { + \Log::error('Error migrating email notification settings from teams table: '.$e->getMessage()); + } } } }; diff --git a/database/migrations/2024_12_05_212631_migrate_discord_notification_settings_from_teams_table.php b/database/migrations/2024_12_05_212631_migrate_discord_notification_settings_from_teams_table.php index 228691acb..ed9e9af82 100644 --- a/database/migrations/2024_12_05_212631_migrate_discord_notification_settings_from_teams_table.php +++ b/database/migrations/2024_12_05_212631_migrate_discord_notification_settings_from_teams_table.php @@ -16,22 +16,26 @@ return new class extends Migration $teams = DB::table('teams')->get(); foreach ($teams as $team) { - DB::table('discord_notification_settings')->updateOrInsert( - ['team_id' => $team->id], - [ - 'discord_enabled' => $team->discord_enabled ?? false, - 'discord_webhook_url' => Crypt::encryptString($team->discord_webhook_url), + try { + DB::table('discord_notification_settings')->updateOrInsert( + ['team_id' => $team->id], + [ + 'discord_enabled' => $team->discord_enabled ?? false, + 'discord_webhook_url' => $team->discord_webhook_url ? Crypt::encryptString($team->discord_webhook_url) : null, - 'deployment_success_discord_notifications' => $team->discord_notifications_deployments ?? false, - 'deployment_failure_discord_notifications' => $team->discord_notifications_deployments ?? true, - 'backup_success_discord_notifications' => $team->discord_notifications_database_backups ?? false, - 'backup_failure_discord_notifications' => $team->discord_notifications_database_backups ?? true, - 'scheduled_task_success_discord_notifications' => $team->discord_notifications_scheduled_tasks ?? false, - 'scheduled_task_failure_discord_notifications' => $team->discord_notifications_scheduled_tasks ?? true, - 'status_change_discord_notifications' => $team->discord_notifications_status_changes ?? false, - 'server_disk_usage_discord_notifications' => $team->discord_notifications_server_disk_usage ?? true, - ] - ); + 'deployment_success_discord_notifications' => $team->discord_notifications_deployments ?? false, + 'deployment_failure_discord_notifications' => $team->discord_notifications_deployments ?? true, + 'backup_success_discord_notifications' => $team->discord_notifications_database_backups ?? false, + 'backup_failure_discord_notifications' => $team->discord_notifications_database_backups ?? true, + 'scheduled_task_success_discord_notifications' => $team->discord_notifications_scheduled_tasks ?? false, + 'scheduled_task_failure_discord_notifications' => $team->discord_notifications_scheduled_tasks ?? true, + 'status_change_discord_notifications' => $team->discord_notifications_status_changes ?? false, + 'server_disk_usage_discord_notifications' => $team->discord_notifications_server_disk_usage ?? true, + ] + ); + } catch (Exception $e) { + \Log::error('Error migrating discord notification settings from teams table: '.$e->getMessage()); + } } Schema::table('teams', function (Blueprint $table) { @@ -67,18 +71,22 @@ return new class extends Migration $settings = DB::table('discord_notification_settings')->get(); foreach ($settings as $setting) { - DB::table('teams') - ->where('id', $setting->team_id) - ->update([ - 'discord_enabled' => $setting->discord_enabled, - 'discord_webhook_url' => Crypt::decryptString($setting->discord_webhook_url), + try { + DB::table('teams') + ->where('id', $setting->team_id) + ->update([ + 'discord_enabled' => $setting->discord_enabled, + 'discord_webhook_url' => Crypt::decryptString($setting->discord_webhook_url), - 'discord_notifications_deployments' => $setting->deployment_success_discord_notifications || $setting->deployment_failure_discord_notifications, - 'discord_notifications_status_changes' => $setting->status_change_discord_notifications, - 'discord_notifications_database_backups' => $setting->backup_success_discord_notifications || $setting->backup_failure_discord_notifications, - 'discord_notifications_scheduled_tasks' => $setting->scheduled_task_success_discord_notifications || $setting->scheduled_task_failure_discord_notifications, - 'discord_notifications_server_disk_usage' => $setting->server_disk_usage_discord_notifications, - ]); + 'discord_notifications_deployments' => $setting->deployment_success_discord_notifications || $setting->deployment_failure_discord_notifications, + 'discord_notifications_status_changes' => $setting->status_change_discord_notifications, + 'discord_notifications_database_backups' => $setting->backup_success_discord_notifications || $setting->backup_failure_discord_notifications, + 'discord_notifications_scheduled_tasks' => $setting->scheduled_task_success_discord_notifications || $setting->scheduled_task_failure_discord_notifications, + 'discord_notifications_server_disk_usage' => $setting->server_disk_usage_discord_notifications, + ]); + } catch (Exception $e) { + \Log::error('Error migrating discord notification settings from teams table: '.$e->getMessage()); + } } } }; diff --git a/database/migrations/2024_12_05_212705_migrate_telegram_notification_settings_from_teams_table.php b/database/migrations/2024_12_05_212705_migrate_telegram_notification_settings_from_teams_table.php index d9d4d6b16..c93569aef 100644 --- a/database/migrations/2024_12_05_212705_migrate_telegram_notification_settings_from_teams_table.php +++ b/database/migrations/2024_12_05_212705_migrate_telegram_notification_settings_from_teams_table.php @@ -13,31 +13,35 @@ return new class extends Migration $teams = DB::table('teams')->get(); foreach ($teams as $team) { - DB::table('telegram_notification_settings')->updateOrInsert( - ['team_id' => $team->id], - [ - 'telegram_enabled' => $team->telegram_enabled ?? false, - 'telegram_token' => Crypt::encryptString($team->telegram_token), - 'telegram_chat_id' => Crypt::encryptString($team->telegram_chat_id), + try { + DB::table('telegram_notification_settings')->updateOrInsert( + ['team_id' => $team->id], + [ + 'telegram_enabled' => $team->telegram_enabled ?? false, + 'telegram_token' => $team->telegram_token ? Crypt::encryptString($team->telegram_token) : null, + 'telegram_chat_id' => $team->telegram_chat_id ? Crypt::encryptString($team->telegram_chat_id) : null, - 'deployment_success_telegram_notifications' => $team->telegram_notifications_deployments ?? false, - 'deployment_failure_telegram_notifications' => $team->telegram_notifications_deployments ?? true, - 'backup_success_telegram_notifications' => $team->telegram_notifications_database_backups ?? false, - 'backup_failure_telegram_notifications' => $team->telegram_notifications_database_backups ?? true, - 'scheduled_task_success_telegram_notifications' => $team->telegram_notifications_scheduled_tasks ?? false, - 'scheduled_task_failure_telegram_notifications' => $team->telegram_notifications_scheduled_tasks ?? true, - 'status_change_telegram_notifications' => $team->telegram_notifications_status_changes ?? false, - 'server_disk_usage_telegram_notifications' => $team->telegram_notifications_server_disk_usage ?? true, + 'deployment_success_telegram_notifications' => $team->telegram_notifications_deployments ?? false, + 'deployment_failure_telegram_notifications' => $team->telegram_notifications_deployments ?? true, + 'backup_success_telegram_notifications' => $team->telegram_notifications_database_backups ?? false, + 'backup_failure_telegram_notifications' => $team->telegram_notifications_database_backups ?? true, + 'scheduled_task_success_telegram_notifications' => $team->telegram_notifications_scheduled_tasks ?? false, + 'scheduled_task_failure_telegram_notifications' => $team->telegram_notifications_scheduled_tasks ?? true, + 'status_change_telegram_notifications' => $team->telegram_notifications_status_changes ?? false, + 'server_disk_usage_telegram_notifications' => $team->telegram_notifications_server_disk_usage ?? true, - 'telegram_notifications_deployment_success_topic_id' => Crypt::encryptString($team->telegram_notifications_deployments_message_thread_id), - 'telegram_notifications_deployment_failure_topic_id' => Crypt::encryptString($team->telegram_notifications_deployments_message_thread_id), - 'telegram_notifications_backup_success_topic_id' => Crypt::encryptString($team->telegram_notifications_database_backups_message_thread_id), - 'telegram_notifications_backup_failure_topic_id' => Crypt::encryptString($team->telegram_notifications_database_backups_message_thread_id), - 'telegram_notifications_scheduled_task_success_topic_id' => Crypt::encryptString($team->telegram_notifications_scheduled_tasks_thread_id), - 'telegram_notifications_scheduled_task_failure_topic_id' => Crypt::encryptString($team->telegram_notifications_scheduled_tasks_thread_id), - 'telegram_notifications_status_change_topic_id' => Crypt::encryptString($team->telegram_notifications_status_changes_message_thread_id), - ] - ); + 'telegram_notifications_deployment_success_topic_id' => $team->telegram_notifications_deployments_message_thread_id ? Crypt::encryptString($team->telegram_notifications_deployments_message_thread_id) : null, + 'telegram_notifications_deployment_failure_topic_id' => $team->telegram_notifications_deployments_message_thread_id ? Crypt::encryptString($team->telegram_notifications_deployments_message_thread_id) : null, + 'telegram_notifications_backup_success_topic_id' => $team->telegram_notifications_database_backups_message_thread_id ? Crypt::encryptString($team->telegram_notifications_database_backups_message_thread_id) : null, + 'telegram_notifications_backup_failure_topic_id' => $team->telegram_notifications_database_backups_message_thread_id ? Crypt::encryptString($team->telegram_notifications_database_backups_message_thread_id) : null, + 'telegram_notifications_scheduled_task_success_topic_id' => $team->telegram_notifications_scheduled_tasks_thread_id ? Crypt::encryptString($team->telegram_notifications_scheduled_tasks_thread_id) : null, + 'telegram_notifications_scheduled_task_failure_topic_id' => $team->telegram_notifications_scheduled_tasks_thread_id ? Crypt::encryptString($team->telegram_notifications_scheduled_tasks_thread_id) : null, + 'telegram_notifications_status_change_topic_id' => $team->telegram_notifications_status_changes_message_thread_id ? Crypt::encryptString($team->telegram_notifications_status_changes_message_thread_id) : null, + ] + ); + } catch (Exception $e) { + \Log::error('Error migrating telegram notification settings from teams table: '.$e->getMessage()); + } } Schema::table('teams', function (Blueprint $table) { @@ -83,24 +87,28 @@ return new class extends Migration $settings = DB::table('telegram_notification_settings')->get(); foreach ($settings as $setting) { - DB::table('teams') - ->where('id', $setting->team_id) - ->update([ - 'telegram_enabled' => $setting->telegram_enabled, - 'telegram_token' => Crypt::decryptString($setting->telegram_token), - 'telegram_chat_id' => Crypt::decryptString($setting->telegram_chat_id), + try { + DB::table('teams') + ->where('id', $setting->team_id) + ->update([ + 'telegram_enabled' => $setting->telegram_enabled, + 'telegram_token' => Crypt::decryptString($setting->telegram_token), + 'telegram_chat_id' => Crypt::decryptString($setting->telegram_chat_id), - 'telegram_notifications_deployments' => $setting->deployment_success_telegram_notifications || $setting->deployment_failure_telegram_notifications, - 'telegram_notifications_status_changes' => $setting->status_change_telegram_notifications, - 'telegram_notifications_database_backups' => $setting->backup_success_telegram_notifications || $setting->backup_failure_telegram_notifications, - 'telegram_notifications_scheduled_tasks' => $setting->scheduled_task_success_telegram_notifications || $setting->scheduled_task_failure_telegram_notifications, - 'telegram_notifications_server_disk_usage' => $setting->server_disk_usage_telegram_notifications, + 'telegram_notifications_deployments' => $setting->deployment_success_telegram_notifications || $setting->deployment_failure_telegram_notifications, + 'telegram_notifications_status_changes' => $setting->status_change_telegram_notifications, + 'telegram_notifications_database_backups' => $setting->backup_success_telegram_notifications || $setting->backup_failure_telegram_notifications, + 'telegram_notifications_scheduled_tasks' => $setting->scheduled_task_success_telegram_notifications || $setting->scheduled_task_failure_telegram_notifications, + 'telegram_notifications_server_disk_usage' => $setting->server_disk_usage_telegram_notifications, - 'telegram_notifications_deployments_message_thread_id' => Crypt::decryptString($setting->telegram_notifications_deployment_success_topic_id), - 'telegram_notifications_status_changes_message_thread_id' => Crypt::decryptString($setting->telegram_notifications_status_change_topic_id), - 'telegram_notifications_database_backups_message_thread_id' => Crypt::decryptString($setting->telegram_notifications_backup_success_topic_id), - 'telegram_notifications_scheduled_tasks_thread_id' => Crypt::decryptString($setting->telegram_notifications_scheduled_task_success_topic_id), - ]); + 'telegram_notifications_deployments_message_thread_id' => Crypt::decryptString($setting->telegram_notifications_deployment_success_topic_id), + 'telegram_notifications_status_changes_message_thread_id' => Crypt::decryptString($setting->telegram_notifications_status_change_topic_id), + 'telegram_notifications_database_backups_message_thread_id' => Crypt::decryptString($setting->telegram_notifications_backup_success_topic_id), + 'telegram_notifications_scheduled_tasks_thread_id' => Crypt::decryptString($setting->telegram_notifications_scheduled_task_success_topic_id), + ]); + } catch (Exception $e) { + \Log::error('Error migrating telegram notification settings from teams table: '.$e->getMessage()); + } } } }; diff --git a/database/migrations/2024_12_10_122142_encrypt_instance_settings_email_columns.php b/database/migrations/2024_12_10_122142_encrypt_instance_settings_email_columns.php index 618b8df90..8ccbcb4f6 100644 --- a/database/migrations/2024_12_10_122142_encrypt_instance_settings_email_columns.php +++ b/database/migrations/2024_12_10_122142_encrypt_instance_settings_email_columns.php @@ -15,22 +15,26 @@ return new class extends Migration { if (DB::table('instance_settings')->exists()) { Schema::table('instance_settings', function (Blueprint $table) { - $table->text('smtp_from_address')->change(); - $table->text('smtp_from_name')->change(); - $table->text('smtp_recipients')->change(); - $table->text('smtp_host')->change(); - $table->text('smtp_username')->change(); + $table->text('smtp_from_address')->nullable()->change(); + $table->text('smtp_from_name')->nullable()->change(); + $table->text('smtp_recipients')->nullable()->change(); + $table->text('smtp_host')->nullable()->change(); + $table->text('smtp_username')->nullable()->change(); }); $settings = DB::table('instance_settings')->get(); foreach ($settings as $setting) { - DB::table('instance_settings')->where('id', $setting->id)->update([ - 'smtp_from_address' => Crypt::encryptString($setting->smtp_from_address), - 'smtp_from_name' => Crypt::encryptString($setting->smtp_from_name), - 'smtp_recipients' => Crypt::encryptString($setting->smtp_recipients), - 'smtp_host' => Crypt::encryptString($setting->smtp_host), - 'smtp_username' => Crypt::encryptString($setting->smtp_username), - ]); + try { + DB::table('instance_settings')->where('id', $setting->id)->update([ + 'smtp_from_address' => $setting->smtp_from_address ? Crypt::encryptString($setting->smtp_from_address) : null, + 'smtp_from_name' => $setting->smtp_from_name ? Crypt::encryptString($setting->smtp_from_name) : null, + 'smtp_recipients' => $setting->smtp_recipients ? Crypt::encryptString($setting->smtp_recipients) : null, + 'smtp_host' => $setting->smtp_host ? Crypt::encryptString($setting->smtp_host) : null, + 'smtp_username' => $setting->smtp_username ? Crypt::encryptString($setting->smtp_username) : null, + ]); + } catch (Exception $e) { + \Log::error('Error encrypting instance settings email columns: '.$e->getMessage()); + } } } } @@ -51,13 +55,17 @@ return new class extends Migration if (DB::table('instance_settings')->exists()) { $settings = DB::table('instance_settings')->get(); foreach ($settings as $setting) { - DB::table('instance_settings')->where('id', $setting->id)->update([ - 'smtp_from_address' => Crypt::decryptString($setting->smtp_from_address), - 'smtp_from_name' => Crypt::decryptString($setting->smtp_from_name), - 'smtp_recipients' => Crypt::decryptString($setting->smtp_recipients), - 'smtp_host' => Crypt::decryptString($setting->smtp_host), - 'smtp_username' => Crypt::decryptString($setting->smtp_username), - ]); + try { + DB::table('instance_settings')->where('id', $setting->id)->update([ + 'smtp_from_address' => $setting->smtp_from_address ? Crypt::decryptString($setting->smtp_from_address) : null, + 'smtp_from_name' => $setting->smtp_from_name ? Crypt::decryptString($setting->smtp_from_name) : null, + 'smtp_recipients' => $setting->smtp_recipients ? Crypt::decryptString($setting->smtp_recipients) : null, + 'smtp_host' => $setting->smtp_host ? Crypt::decryptString($setting->smtp_host) : null, + 'smtp_username' => $setting->smtp_username ? Crypt::decryptString($setting->smtp_username) : null, + ]); + } catch (Exception $e) { + \Log::error('Error decrypting instance settings email columns: '.$e->getMessage()); + } } } } diff --git a/resources/views/livewire/notifications/discord.blade.php b/resources/views/livewire/notifications/discord.blade.php index 7a00df6ea..189f2f490 100644 --- a/resources/views/livewire/notifications/discord.blade.php +++ b/resources/views/livewire/notifications/discord.blade.php @@ -14,6 +14,10 @@ wire:click="sendTestNotification"> Send Test Notification + @else + + Send Test Notification + @endif
@@ -23,44 +27,53 @@ helper="Generate a webhook in Discord.
Example: https://discord.com/api/webhooks/...." required id="discordWebhookUrl" label="Webhook" /> - @if ($discordEnabled) -

Notification Settings

-

- Select events for which you would like to receive Discord notifications. -

-
-
-

Deployments

-
- - - {{-- --}} -
+

Notification Settings

+

+ Select events for which you would like to receive Discord notifications. +

+
+
+

Deployments

+
+ + + {{-- --}}
-
-

Backups

-
- - -
+
+
+

Backups

+
+ +
-
-

Scheduled Tasks

-
- - -
+
+
+

Scheduled Tasks

+
+ +
-
-

Server

-
- - - - - -
+
+
+

Server

+
+ + + + +
-
- @endif +
+
diff --git a/resources/views/livewire/notifications/email.blade.php b/resources/views/livewire/notifications/email.blade.php index 980525cce..37bfac0e0 100644 --- a/resources/views/livewire/notifications/email.blade.php +++ b/resources/views/livewire/notifications/email.blade.php @@ -1,48 +1,58 @@
Notifications | Coolify - - -
-
-

Email

- - Save - - @if ($team->isNotificationEnabled('email') && auth()->user()->isAdminFromSession()) - - - - - Send Email - - - + + +
+
+

Email

+ + Save + + @if (auth()->user()->isAdminFromSession()) + @if ($team->isNotificationEnabled('email')) + + + + + Send Email + + + + @else + + Send Test Email + @endif - @if (isInstanceAdmin() && !$useInstanceEmailSettings) + @endif +
+ @if (!isCloud()) +
+ +
+ @endif + @if (!$useInstanceEmailSettings) +
+ + +
+ @if (isInstanceAdmin() && !$useInstanceEmailSettings) Copy from Instance Settings - @endif -
- @if (!isCloud()) -
- -
@endif - @if (!$useInstanceEmailSettings) -
- - -
- @endif - - @if (isCloud()) -
- -
@endif - @if (!$useInstanceEmailSettings) + + @if (isCloud()) +
+ +
+ @endif + @if (!$useInstanceEmailSettings)
@@ -52,7 +62,8 @@
- +
@@ -68,7 +79,8 @@
- +
@@ -81,56 +93,68 @@
- +
- +
- @endif - @if ($team->isNotificationEnabled('email') || $useInstanceEmailSettings) -

Notification Settings

-

- Select events for which you would like to receive email notifications. -

-
-
-

Deployments

-
- - - {{-- --}} -
-
-
-

Backups

-
- - -
-
-
-

Scheduled Tasks

-
- - -
-
-
-

Server

-
- - - - - -
+ @endif +

Notification Settings

+

+ Select events for which you would like to receive email notifications. +

+
+
+

Deployments

+
+ + + {{-- --}}
- @endif +
+

Backups

+
+ + +
+
+
+

Scheduled Tasks

+
+ + +
+
+
+

Server

+
+ + + + + +
+
+
diff --git a/resources/views/livewire/notifications/slack.blade.php b/resources/views/livewire/notifications/slack.blade.php index b1d58d72b..9ed28d4ec 100644 --- a/resources/views/livewire/notifications/slack.blade.php +++ b/resources/views/livewire/notifications/slack.blade.php @@ -3,7 +3,7 @@ Notifications | Coolify -
+

Slack

@@ -14,6 +14,10 @@ wire:click="sendTestNotification"> Send Test Notification + @else + + Send Test Notification + @endif
@@ -23,44 +27,51 @@ helper="Generate a webhook in Slack.
Example: https://hooks.slack.com/services/...." required id="slackWebhookUrl" label="Webhook" /> - @if ($slackEnabled) -

Notification Settings

-

- Select events for which you would like to receive Slack notifications. -

-
-
-

Deployments

-
- - - {{-- --}} -
-
-
-

Backups

-
- - -
-
-
-

Scheduled Tasks

-
- - -
-
-
-

Server

-
- - - - - -
+

Notification Settings

+

+ Select events for which you would like to receive Slack notifications. +

+
+
+

Deployments

+
+ + + {{-- --}}
- @endif -
\ No newline at end of file +
+

Backups

+
+ + +
+
+
+

Scheduled Tasks

+
+ + +
+
+
+

Server

+
+ + + + + +
+
+
+
diff --git a/resources/views/livewire/notifications/telegram.blade.php b/resources/views/livewire/notifications/telegram.blade.php index ff60673b0..f1d2cb540 100644 --- a/resources/views/livewire/notifications/telegram.blade.php +++ b/resources/views/livewire/notifications/telegram.blade.php @@ -1,122 +1,162 @@
Notifications | Coolify - - -
-
-

Telegram

- - Save - - @if ($telegramEnabled) - + + + +
+

Telegram

+ + Save + + @if ($telegramEnabled) + + Send Test Notification + + @else + Send Test Notification - @endif -
-
- -
-
- - -
- @if ($telegramEnabled) -

Notification Settings

-

- Select events for which you would like to receive Telegram notifications. -

-
-
-

Deployment

-
-

Deployment Success

-
- - -
-

Deployment Failure

-
- - -
- {{--

Container Status Changes

-
- - -
--}} -
-
-
-

Backups

-
-

Backup Success

-
- - -
- -

Backup Failure

-
- - -
-
-
- -
-

Scheduled Tasks

-
-

Scheduled Task Success

-
- - -
- -

Scheduled Task Failure

-
- - -
-
-
- -
-

Server

-
-

Docker Cleanup Success

-
- - -
- -

Docker Cleanup Failure

-
- - -
- -

Server Disk Usage

-
- - -
- -

Server Reachable

-
- - -
- -

Server Unreachable

-
- - -
-
-
-
@endif - +
+
+ +
+
+ + +
+ +

Notification Settings

+

+ Select events for which you would like to receive Telegram notifications. +

+
+
+

Deployments

+
+
+
+ +
+ +
+
+
+ +
+ +
+ {{--

Container Status Changes

+
+ + +
--}} +
+
+
+

Backups

+
+
+
+ +
+ +
+ +
+
+ +
+ +
+
+
+ +
+

Scheduled Tasks

+
+
+
+ +
+ +
+ +
+
+ +
+ +
+
+
+ +
+

Server

+
+
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ + +
+
+ +
+ +
+
+
+
diff --git a/scripts/run b/scripts/run index 8764ef23f..466b04530 100755 --- a/scripts/run +++ b/scripts/run @@ -32,18 +32,18 @@ function sync:bunny { } function db:reset { - bash spin exec -u webuser coolify php artisan migrate:fresh --seed + bash spin exec -u www-data coolify php artisan migrate:fresh --seed } function db:reset-prod { - bash spin exec -u webuser coolify php artisan migrate:fresh --force --seed --seeder=ProductionSeeder || + bash spin exec -u www-data coolify php artisan migrate:fresh --force --seed --seeder=ProductionSeeder || php artisan migrate:fresh --force --seed --seeder=ProductionSeeder } function coolify { - bash spin exec -u webuser coolify bash + bash spin exec -u www-data coolify sh } function coolify:root { - bash spin exec coolify bash + bash spin exec coolify sh } function coolify:proxy { docker exec -ti coolify-proxy sh @@ -58,7 +58,7 @@ function vite { } function tinker { - bash spin exec -u webuser coolify php artisan tinker + bash spin exec -u www-data coolify php artisan tinker } function default { @@ -66,4 +66,4 @@ function default { } TIMEFORMAT="Task completed in %3lR" -time "${@:-default}" \ No newline at end of file +time "${@:-default}"