From de839e3fcb788a200a0d42fce788a302f11d3e15 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Sat, 12 Apr 2025 13:59:54 +0200 Subject: [PATCH] refactor(Email): streamline SMTP and resend settings handling in copyFromInstanceSettings method --- app/Livewire/Notifications/Email.php | 31 +++++++++++++--------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/app/Livewire/Notifications/Email.php b/app/Livewire/Notifications/Email.php index 3ed20f907..3b732af99 100644 --- a/app/Livewire/Notifications/Email.php +++ b/app/Livewire/Notifications/Email.php @@ -337,32 +337,29 @@ class Email extends Component public function copyFromInstanceSettings() { $settings = instanceSettings(); + $this->smtpFromAddress = $settings->smtp_from_address; + $this->smtpFromName = $settings->smtp_from_name; if ($settings->smtp_enabled) { $this->smtpEnabled = true; - $this->smtpFromAddress = $settings->smtp_from_address; - $this->smtpFromName = $settings->smtp_from_name; - $this->smtpRecipients = $settings->smtp_recipients; - $this->smtpHost = $settings->smtp_host; - $this->smtpPort = $settings->smtp_port; - $this->smtpEncryption = $settings->smtp_encryption; - $this->smtpUsername = $settings->smtp_username; - $this->smtpPassword = $settings->smtp_password; - $this->smtpTimeout = $settings->smtp_timeout; $this->resendEnabled = false; - $this->saveModel(); - - return; } + + $this->smtpRecipients = $settings->smtp_recipients; + $this->smtpHost = $settings->smtp_host; + $this->smtpPort = $settings->smtp_port; + $this->smtpEncryption = $settings->smtp_encryption; + $this->smtpUsername = $settings->smtp_username; + $this->smtpPassword = $settings->smtp_password; + $this->smtpTimeout = $settings->smtp_timeout; + if ($settings->resend_enabled) { $this->resendEnabled = true; - $this->resendApiKey = $settings->resend_api_key; $this->smtpEnabled = false; - $this->saveModel(); - - return; } - $this->dispatch('error', 'Instance SMTP/Resend settings are not enabled.'); + $this->resendApiKey = $settings->resend_api_key; + $this->saveModel(); + } public function render()