fix: send internal notifications of email errors
This commit is contained in:
		@@ -69,14 +69,6 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
 | 
			
		||||
 | 
			
		||||
    public function restartBoarding()
 | 
			
		||||
    {
 | 
			
		||||
        // if ($this->selectedServerType !== 'localhost') {
 | 
			
		||||
        //     if ($this->createdServer) {
 | 
			
		||||
        //         $this->createdServer->delete();
 | 
			
		||||
        //     }
 | 
			
		||||
        //     if ($this->createdPrivateKey) {
 | 
			
		||||
        //         $this->createdPrivateKey->delete();
 | 
			
		||||
        //     }
 | 
			
		||||
        // }
 | 
			
		||||
        return redirect()->route('boarding');
 | 
			
		||||
    }
 | 
			
		||||
    public function skipBoarding()
 | 
			
		||||
 
 | 
			
		||||
@@ -86,7 +86,6 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted
 | 
			
		||||
                    $this->server->team->notify(new ContainerRestarted('coolify-proxy', $this->server));
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
                ray($foundProxyContainer);
 | 
			
		||||
                $this->server->proxy->status = data_get($foundProxyContainer, 'State.Status');
 | 
			
		||||
                $this->server->save();
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -14,7 +14,7 @@ class DeploymentFailed extends Notification implements ShouldQueue
 | 
			
		||||
{
 | 
			
		||||
    use Queueable;
 | 
			
		||||
 | 
			
		||||
    public $tries = 5;
 | 
			
		||||
    public $tries = 1;
 | 
			
		||||
    public Application $application;
 | 
			
		||||
    public ?ApplicationPreview $preview = null;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -14,7 +14,7 @@ class DeploymentSuccess extends Notification implements ShouldQueue
 | 
			
		||||
{
 | 
			
		||||
    use Queueable;
 | 
			
		||||
 | 
			
		||||
    public $tries = 5;
 | 
			
		||||
    public $tries = 1;
 | 
			
		||||
    public Application $application;
 | 
			
		||||
    public ApplicationPreview|null $preview = null;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,7 @@ class StatusChanged extends Notification implements ShouldQueue
 | 
			
		||||
{
 | 
			
		||||
    use Queueable;
 | 
			
		||||
 | 
			
		||||
    public $tries = 5;
 | 
			
		||||
    public $tries = 1;
 | 
			
		||||
 | 
			
		||||
    public Application $application;
 | 
			
		||||
    public string $application_name;
 | 
			
		||||
 
 | 
			
		||||
@@ -12,23 +12,29 @@ class EmailChannel
 | 
			
		||||
{
 | 
			
		||||
    public function send(SendsEmail $notifiable, Notification $notification): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->bootConfigs($notifiable);
 | 
			
		||||
        $recepients = $notifiable->getRecepients($notification);
 | 
			
		||||
        try {
 | 
			
		||||
            $this->bootConfigs($notifiable);
 | 
			
		||||
            $recepients = $notifiable->getRecepients($notification);
 | 
			
		||||
            ray($recepients);
 | 
			
		||||
            if (count($recepients) === 0) {
 | 
			
		||||
                throw new Exception('No email recipients found');
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        if (count($recepients) === 0) {
 | 
			
		||||
            throw new Exception('No email recipients found');
 | 
			
		||||
            $mailMessage = $notification->toMail($notifiable);
 | 
			
		||||
            throw new Exception('EmailChannel is disabled');
 | 
			
		||||
            Mail::send(
 | 
			
		||||
                [],
 | 
			
		||||
                [],
 | 
			
		||||
                fn (Message $message) => $message
 | 
			
		||||
                    ->to($recepients)
 | 
			
		||||
                    ->subject($mailMessage->subject)
 | 
			
		||||
                    ->html((string)$mailMessage->render())
 | 
			
		||||
            );
 | 
			
		||||
        } catch (Exception $e) {
 | 
			
		||||
            ray($e->getMessage());
 | 
			
		||||
            send_internal_notification("EmailChannel error: {$e->getMessage()}. Failed to send email to: " . implode(', ', $recepients) . " with subject: {$mailMessage->subject}");
 | 
			
		||||
            throw $e;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $mailMessage = $notification->toMail($notifiable);
 | 
			
		||||
        ray("Sending email to: " . implode(', ', $recepients) . " with subject: {$mailMessage->subject}");
 | 
			
		||||
        Mail::send(
 | 
			
		||||
            [],
 | 
			
		||||
            [],
 | 
			
		||||
            fn (Message $message) => $message
 | 
			
		||||
                ->to($recepients)
 | 
			
		||||
                ->subject($mailMessage->subject)
 | 
			
		||||
                ->html((string)$mailMessage->render())
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private function bootConfigs($notifiable): void
 | 
			
		||||
 
 | 
			
		||||
@@ -3,8 +3,6 @@
 | 
			
		||||
namespace App\Notifications\Database;
 | 
			
		||||
 | 
			
		||||
use App\Models\ScheduledDatabaseBackup;
 | 
			
		||||
use App\Notifications\Channels\DiscordChannel;
 | 
			
		||||
use App\Notifications\Channels\EmailChannel;
 | 
			
		||||
use Illuminate\Bus\Queueable;
 | 
			
		||||
use Illuminate\Contracts\Queue\ShouldQueue;
 | 
			
		||||
use Illuminate\Notifications\Messages\MailMessage;
 | 
			
		||||
@@ -14,7 +12,7 @@ class BackupFailed extends Notification implements ShouldQueue
 | 
			
		||||
{
 | 
			
		||||
    use Queueable;
 | 
			
		||||
 | 
			
		||||
    public $tries = 5;
 | 
			
		||||
    public $tries = 1;
 | 
			
		||||
    public string $name;
 | 
			
		||||
    public string $frequency;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -3,8 +3,6 @@
 | 
			
		||||
namespace App\Notifications\Database;
 | 
			
		||||
 | 
			
		||||
use App\Models\ScheduledDatabaseBackup;
 | 
			
		||||
use App\Notifications\Channels\DiscordChannel;
 | 
			
		||||
use App\Notifications\Channels\EmailChannel;
 | 
			
		||||
use Illuminate\Bus\Queueable;
 | 
			
		||||
use Illuminate\Contracts\Queue\ShouldQueue;
 | 
			
		||||
use Illuminate\Notifications\Messages\MailMessage;
 | 
			
		||||
@@ -14,7 +12,7 @@ class BackupSuccess extends Notification implements ShouldQueue
 | 
			
		||||
{
 | 
			
		||||
    use Queueable;
 | 
			
		||||
 | 
			
		||||
    public $tries = 5;
 | 
			
		||||
    public $tries = 1;
 | 
			
		||||
    public string $name;
 | 
			
		||||
    public string $frequency;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user