refactor(notifications): Improve transactional email settings handling
- Replace `! $type` checks with `blank($type)` for consistency - Modify email settings configuration to handle null/disabled states - Ensure proper fallback and configuration of email providers
This commit is contained in:
@@ -54,7 +54,7 @@ class Controller extends BaseController
|
||||
'email' => Str::lower($arrayOfRequest['email']),
|
||||
]);
|
||||
$type = set_transanctional_email_settings();
|
||||
if (! $type) {
|
||||
if (blank($type)) {
|
||||
return response()->json(['message' => 'Transactional emails are not active'], 400);
|
||||
}
|
||||
$request->validate([Fortify::email() => 'required|email']);
|
||||
|
||||
@@ -36,7 +36,7 @@ class Help extends Component
|
||||
$type = set_transanctional_email_settings($settings);
|
||||
|
||||
// Sending feedback through Cloud API
|
||||
if ($type === false) {
|
||||
if (blank($type)) {
|
||||
$url = 'https://app.coolify.io/api/feedback';
|
||||
Http::post($url, [
|
||||
'content' => 'User: `'.auth()->user()?->email.'` with subject: `'.$this->subject.'` has the following problem: `'.$this->description.'`',
|
||||
|
||||
@@ -50,11 +50,9 @@ class EmailChannel
|
||||
|
||||
if ($emailSettings->use_instance_email_settings) {
|
||||
$type = set_transanctional_email_settings();
|
||||
if (! $type) {
|
||||
if (blank($type)) {
|
||||
throw new Exception('No email settings found.');
|
||||
}
|
||||
config()->set('mail.default', $type);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class TransactionalEmailChannel
|
||||
private function bootConfigs(): void
|
||||
{
|
||||
$type = set_transanctional_email_settings();
|
||||
if (! $type) {
|
||||
if (blank($type)) {
|
||||
throw new Exception('No email settings found.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Notifications\TransactionalEmails;
|
||||
|
||||
use App\Models\InstanceSettings;
|
||||
use Exception;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
@@ -35,8 +36,8 @@ class ResetPassword extends Notification
|
||||
public function via($notifiable)
|
||||
{
|
||||
$type = set_transanctional_email_settings();
|
||||
if (! $type) {
|
||||
throw new \Exception('No email settings found.');
|
||||
if (blank($type)) {
|
||||
throw new Exception('No email settings found.');
|
||||
}
|
||||
|
||||
return ['mail'];
|
||||
|
||||
Reference in New Issue
Block a user