feat: new shared function name is_transactional_emails_enabled()

This commit is contained in:
peaklabs-dev
2024-12-09 15:34:24 +01:00
parent ee7a901a77
commit b13d77377c
7 changed files with 8 additions and 13 deletions

View File

@@ -48,7 +48,7 @@ class Controller extends BaseController
public function forgot_password(Request $request)
{
if (is_transactional_emails_active()) {
if (is_transactional_emails_enabled()) {
$arrayOfRequest = $request->only(Fortify::email());
$request->merge([
'email' => Str::lower($arrayOfRequest['email']),

View File

@@ -201,7 +201,7 @@ class SettingsEmail extends Component
} catch (\Throwable $e) {
$this->resendEnabled = false;
return handleError($e, $this);
return handleError($e);
}
}
@@ -229,12 +229,7 @@ class SettingsEmail extends Component
throw new \Exception('Too many messages sent!');
}
} catch (\Throwable $e) {
return handleError($e, $this);
return handleError($e);
}
}
public function isEmailEnabled(): bool
{
return $this->settings->smtp_enabled || $this->settings->resend_enabled;
}
}

View File

@@ -59,7 +59,7 @@ class S3Storage extends BaseModel
$this->is_usable = true;
} catch (\Throwable $e) {
$this->is_usable = false;
if ($this->unusable_email_sent === false && is_transactional_emails_active()) {
if ($this->unusable_email_sent === false && is_transactional_emails_enabled()) {
$mail = new MailMessage;
$mail->subject('Coolify: S3 Storage Connection Error');
$mail->view('emails.s3-connection-error', ['name' => $this->name, 'reason' => $e->getMessage(), 'url' => route('storage.show', ['storage_uuid' => $this->uuid])]);

View File

@@ -9,7 +9,7 @@
<div
class="w-full bg-white shadow md:mt-0 sm:max-w-md xl:p-0 dark:bg-base ">
<div class="p-6 space-y-4 md:space-y-6 sm:p-8">
@if (is_transactional_emails_active())
@if (is_transactional_emails_enabled())
<form action="/forgot-password" method="POST" class="flex flex-col gap-2">
@csrf
<x-forms.input required type="email" name="email" label="{{ __('input.email') }}" />

View File

@@ -9,7 +9,7 @@
<x-forms.button type="submit">
Save
</x-forms.button>
@if ($this->isEmailEnabled() && auth()->user()->isAdminFromSession())
@if (is_transactional_emails_enabled() && auth()->user()->isAdminFromSession())
<x-modal-input buttonTitle="Send Test Email" title="Send Test Email">
<form wire:submit.prevent="sendTestEmail" class="flex flex-col w-full gap-2">
<x-forms.input wire:model="testEmailAddress" placeholder="test@example.com" id="testEmailAddress" label="Recipients" required />

View File

@@ -11,7 +11,7 @@
</div>
<div class="flex gap-2">
<x-forms.button type="submit">Generate Invitation Link</x-forms.button>
@if (is_transactional_emails_active())
@if (is_transactional_emails_enabled())
<x-forms.button wire:click.prevent='viaEmail'>Send Invitation via Email</x-forms.button>
@endif
</div>

View File

@@ -33,7 +33,7 @@
</div>
@if (auth()->user()->isAdminFromSession())
<div class="py-4">
@if (is_transactional_emails_active())
@if (is_transactional_emails_enabled())
<h2 class="pb-4">Invite New Member</h2>
@else
<h2>Invite New Member</h2>