Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: Email should be retried with backoff

Andras Bacsaidabda4e806d1
diff --git a/app/Console/Commands/Emails.php b/app/Console/Commands/Emails.php
index cda4ca84f1..f0e0e7fa07 100644
--- a/app/Console/Commands/Emails.php
+++ b/app/Console/Commands/Emails.php
@@ -187,7 +187,7 @@ class Emails extends Command
'team_id' => 0,
]);
}
- $this->mail = (new BackupSuccess($backup, $db))->toMail();
+ // $this->mail = (new BackupSuccess($backup->frequency, $db->name))->toMail();
$this->sendEmail();
break;
// case 'invitation-link':
diff --git a/app/Jobs/ServerCheckJob.php b/app/Jobs/ServerCheckJob.php
index 9818d5c6a0..49d8dfe08f 100644
--- a/app/Jobs/ServerCheckJob.php
+++ b/app/Jobs/ServerCheckJob.php
@@ -31,7 +31,12 @@ class ServerCheckJob implements ShouldBeEncrypted, ShouldQueue
return [(new WithoutOverlapping($this->server->uuid))->dontRelease()];
}
- public function __construct(public Server $server) {}
+ public function __construct(public Server $server)
+ {
+ if (isDev()) {
+ $this->handle();
+ }
+ }
public function handle()
{
diff --git a/app/Notifications/Application/DeploymentFailed.php b/app/Notifications/Application/DeploymentFailed.php
index fae8951fd6..ce1f99d77b 100644
--- a/app/Notifications/Application/DeploymentFailed.php
+++ b/app/Notifications/Application/DeploymentFailed.php
@@ -4,18 +4,12 @@ namespace App\Notifications\Application;
use App\Models\Application;
use App\Models\ApplicationPreview;
+use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
-use Illuminate\Notifications\Notification;
-class DeploymentFailed extends Notification implements ShouldQueue
+class DeploymentFailed extends CustomEmailNotification
{
- use Queueable;
-
- public $tries = 1;
-
public Application $application;
public ?ApplicationPreview $preview = null;
diff --git a/app/Notifications/Application/DeploymentSuccess.php b/app/Notifications/Application/DeploymentSuccess.php
index bfdef9f257..3916012571 100644
--- a/app/Notifications/Application/DeploymentSuccess.php
+++ b/app/Notifications/Application/DeploymentSuccess.php
@@ -4,18 +4,12 @@ namespace App\Notifications\Application;
use App\Models\Application;
use App\Models\ApplicationPreview;
+use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
-use Illuminate\Notifications\Notification;
-class DeploymentSuccess extends Notification implements ShouldQueue
+class DeploymentSuccess extends CustomEmailNotification
{
- use Queueable;
-
- public $tries = 1;
-
public Application $application;
public ?ApplicationPreview $preview = null;
diff --git a/app/Notifications/Application/StatusChanged.php b/app/Notifications/Application/StatusChanged.php
index 3b062effbf..c757495cb5 100644
--- a/app/Notifications/Application/StatusChanged.php
+++ b/app/Notifications/Application/StatusChanged.php
@@ -3,18 +3,12 @@
namespace App\Notifications\Application;
use App\Models\Application;
+use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
-use Illuminate\Notifications\Notification;
-class StatusChanged extends Notification implements ShouldQueue
+class StatusChanged extends CustomEmailNotification
{
- use Queueable;
-
- public $tries = 1;
-
public string $resource_name;
public string $project_uuid;
diff --git a/app/Notifications/Container/ContainerRestarted.php b/app/Notifications/Container/ContainerRestarted.php
index 90dae63d4c..eb709535f4 100644
--- a/app/Notifications/Container/ContainerRestarted.php
+++ b/app/Notifications/Container/ContainerRestarted.php
@@ -3,18 +3,12 @@
namespace App\Notifications\Container;
use App\Models\Server;
+use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
-use Illuminate\Notifications\Notification;
-class ContainerRestarted extends Notification implements ShouldQueue
+class ContainerRestarted extends CustomEmailNotification
{
- use Queueable;
-
- public $tries = 1;
-
public function __construct(public string $name, public Server $server, public ?string $url = null)
{
$this->onQueue('high');
diff --git a/app/Notifications/Container/ContainerStopped.php b/app/Notifications/Container/ContainerStopped.php
index 3c81035687..a73e984a01 100644
--- a/app/Notifications/Container/ContainerStopped.php
+++ b/app/Notifications/Container/ContainerStopped.php
@@ -3,18 +3,12 @@
namespace App\Notifications\Container;
use App\Models\Server;
+use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
-use Illuminate\Notifications\Notification;
-class ContainerStopped extends Notification implements ShouldQueue
+class ContainerStopped extends CustomEmailNotification
{
- use Queueable;
-
- public $tries = 1;
-
public function __construct(public string $name, public Server $server, public ?string $url = null)
{
$this->onQueue('high');
diff --git a/app/Notifications/CustomEmailNotification.php b/app/Notifications/CustomEmailNotification.php
new file mode 100644
index 0000000000..c3c89b30f4
--- /dev/null
+++ b/app/Notifications/CustomEmailNotification.php
@@ -0,0 +1,18 @@
+<?php
+
+namespace App\Notifications;
+
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Notifications\Notification;
+
+class CustomEmailNotification extends Notification implements ShouldQueue
+{
+ use Queueable;
+
+ public $backoff = [10, 20, 30, 40, 50];
+
+ public $tries = 5;
+
+ public $maxExceptions = 5;
+}
diff --git a/app/Notifications/Database/BackupFailed.php b/app/Notifications/Database/BackupFailed.php
index ba67db4ae9..beeea08042 100644
--- a/app/Notifications/Database/BackupFailed.php
+++ b/app/Notifications/Database/BackupFailed.php
@@ -3,20 +3,12 @@
namespace App\Notifications\Database;
use App\Models\ScheduledDatabaseBackup;
+use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
-use Illuminate\Notifications\Notification;
-class BackupFailed extends Notification implements ShouldQueue
+class BackupFailed extends CustomEmailNotification
{
- use Queueable;
-
- public $backoff = 10;
-
- public $tries = 2;
-
public string $name;
public string $frequency;
diff --git a/app/Notifications/Database/BackupSuccess.php b/app/Notifications/Database/BackupSuccess.php
index 669a8a0343..d8bab069be 100644
--- a/app/Notifications/Database/BackupSuccess.php
+++ b/app/Notifications/Database/BackupSuccess.php
@@ -3,20 +3,12 @@
namespace App\Notifications\Database;
use App\Models\ScheduledDatabaseBackup;
+use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
-use Illuminate\Notifications\Notification;
-class BackupSuccess extends Notification implements ShouldQueue
+class BackupSuccess extends CustomEmailNotification
{
- use Queueable;
-
- public $backoff = 10;
-
- public $tries = 3;
-
public string $name;
public string $frequency;
@@ -24,6 +16,7 @@ class BackupSuccess extends Notification implements ShouldQueue
public function __construct(ScheduledDatabaseBackup $backup, public $database, public $database_name)
{
$this->onQueue('high');
+
$this->name = $database->name;
$this->frequency = $backup->frequency;
}
diff --git a/app/Notifications/ScheduledTask/TaskFailed.php b/app/Notifications/ScheduledTask/TaskFailed.php
index efdb8dccf6..701f612776 100644
--- a/app/Notifications/ScheduledTask/TaskFailed.php
+++ b/app/Notifications/ScheduledTask/TaskFailed.php
@@ -3,20 +3,12 @@
namespace App\Notifications\ScheduledTask;
use App\Models\ScheduledTask;
+use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
-use Illuminate\Notifications\Notification;
-class TaskFailed extends Notification implements ShouldQueue
+class TaskFailed extends CustomEmailNotification
{
- use Queueable;
-
- public $backoff = 10;
-
- public $tries = 2;
-
public ?string $url = null;
public function __construct(public ScheduledTask $task, public string $output)
diff --git a/app/Notifications/Server/DockerCleanup.php b/app/Notifications/Server/DockerCleanup.php
index 7e9425bb34..2d007a262d 100644
--- a/app/Notifications/Server/DockerCleanup.php
+++ b/app/Notifications/Server/DockerCleanup.php
@@ -5,17 +5,11 @@ namespace App\Notifications\Server;
use App\Models\Server;
use App\Notifications\Channels\DiscordChannel;
use App\Notifications\Channels\TelegramChannel;
+use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
-use Illuminate\Notifications\Notification;
-class DockerCleanup extends Notification implements ShouldQueue
+class DockerCleanup extends CustomEmailNotification
{
- use Queueable;
-
- public $tries = 1;
-
public function __construct(public Server $server, public string $message)
{
$this->onQueue('high');
diff --git a/app/Notifications/Server/ForceDisabled.php b/app/Notifications/Server/ForceDisabled.php
index 0008e3ed7c..eabf8b334d 100644
--- a/app/Notifications/Server/ForceDisabled.php
+++ b/app/Notifications/Server/ForceDisabled.php
@@ -6,18 +6,12 @@ use App\Models\Server;
use App\Notifications\Channels\DiscordChannel;
use App\Notifications\Channels\EmailChannel;
use App\Notifications\Channels\TelegramChannel;
+use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
-use Illuminate\Notifications\Notification;
-class ForceDisabled extends Notification implements ShouldQueue
+class ForceDisabled extends CustomEmailNotification
{
- use Queueable;
-
- public $tries = 1;
-
public function __construct(public Server $server)
{
$this->onQueue('high');
diff --git a/app/Notifications/Server/ForceEnabled.php b/app/Notifications/Server/ForceEnabled.php
index 15288ddcfc..0c21ed6b8e 100644
--- a/app/Notifications/Server/ForceEnabled.php
+++ b/app/Notifications/Server/ForceEnabled.php
@@ -6,18 +6,12 @@ use App\Models\Server;
use App\Notifications\Channels\DiscordChannel;
use App\Notifications\Channels\EmailChannel;
use App\Notifications\Channels\TelegramChannel;
+use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
-use Illuminate\Notifications\Notification;
-class ForceEnabled extends Notification implements ShouldQueue
+class ForceEnabled extends CustomEmailNotification
{
- use Queueable;
-
- public $tries = 1;
-
public function __construct(public Server $server)
{
$this->onQueue('high');
diff --git a/app/Notifications/Server/HighDiskUsage.php b/app/Notifications/Server/HighDiskUsage.php
index d07af0f244..7cec2e8929 100644
--- a/app/Notifications/Server/HighDiskUsage.php
+++ b/app/Notifications/Server/HighDiskUsage.php
@@ -3,18 +3,12 @@
namespace App\Notifications\Server;
use App\Models\Server;
+use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
-use Illuminate\Notifications\Notification;
-class HighDiskUsage extends Notification implements ShouldQueue
+class HighDiskUsage extends CustomEmailNotification
{
- use Queueable;
-
- public $tries = 1;
-
public function __construct(public Server $server, public int $disk_usage, public int $server_disk_usage_notification_threshold)
{
$this->onQueue('high');
diff --git a/app/Notifications/Server/Reachable.php b/app/Notifications/Server/Reachable.php
index dc8ff6bad9..44189c3b5e 100644
--- a/app/Notifications/Server/Reachable.php
+++ b/app/Notifications/Server/Reachable.php
@@ -6,18 +6,12 @@ use App\Models\Server;
use App\Notifications\Channels\DiscordChannel;
use App\Notifications\Channels\EmailChannel;
use App\Notifications\Channels\TelegramChannel;
+use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
-use Illuminate\Notifications\Notification;
-class Reachable extends Notification implements ShouldQueue
+class Reachable extends CustomEmailNotification
{
- use Queueable;
-
- public $tries = 1;
-
protected bool $isRateLimited = false;
public function __construct(public Server $server)
diff --git a/app/Notifications/Server/Unreachable.php b/app/Notifications/Server/Unreachable.php
index c28877aa04..6fb792bdc9 100644
--- a/app/Notifications/Server/Unreachable.php
+++ b/app/Notifications/Server/Unreachable.php
@@ -6,18 +6,12 @@ use App\Models\Server;
use App\Notifications\Channels\DiscordChannel;
use App\Notifications\Channels\EmailChannel;
use App\Notifications\Channels\TelegramChannel;
+use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
-use Illuminate\Notifications\Notification;
-class Unreachable extends Notification implements ShouldQueue
+class Unreachable extends CustomEmailNotification
{
- use Queueable;
-
- public $tries = 1;
-
protected bool $isRateLimited = false;
public function __construct(public Server $server)
diff --git a/app/Notifications/TransactionalEmails/InvitationLink.php b/app/Notifications/TransactionalEmails/InvitationLink.php
index eef7ba0e5d..30ace99dcb 100644
--- a/app/Notifications/TransactionalEmails/InvitationLink.php
+++ b/app/Notifications/TransactionalEmails/InvitationLink.php
@@ -6,17 +6,11 @@ use App\Models\Team;
use App\Models\TeamInvitation;
use App\Models\User;
use App\Notifications\Channels\TransactionalEmailChannel;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
+use App\Notifications\CustomEmailNotification;
use Illuminate\Notifications\Messages\MailMessage;
-use Illuminate\Notifications\Notification;
-class InvitationLink extends Notification implements ShouldQueue
+class InvitationLink extends CustomEmailNotification
{
- use Queueable;
-
- public $tries = 5;
-
public function via(): array
{
return [TransactionalEmailChannel::class];
diff --git a/app/Notifications/TransactionalEmails/Test.php b/app/Notifications/TransactionalEmails/Test.php
index b3cc796048..eeb32a2545 100644
--- a/app/Notifications/TransactionalEmails/Test.php
+++ b/app/Notifications/TransactionalEmails/Test.php
@@ -3,17 +3,11 @@
namespace App\Notifications\TransactionalEmails;
use App\Notifications\Channels\EmailChannel;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
+use App\Notifications\CustomEmailNotification;
use Illuminate\Notifications\Messages\MailMessage;
-use Illuminate\Notifications\Notification;
-class Test extends Notification implements ShouldQueue
+class Test extends CustomEmailNotification
{
- use Queueable;
-
- public $tries = 5;
-
public function __construct(public string $emails)
{
$this->onQueue('high');