diff --git a/app/Console/Commands/Emails.php b/app/Console/Commands/Emails.php index d6a882740..67c50675f 100644 --- a/app/Console/Commands/Emails.php +++ b/app/Console/Commands/Emails.php @@ -6,6 +6,7 @@ use App\Models\Application; use App\Models\ApplicationPreview; use App\Models\ScheduledDatabaseBackup; +use App\Models\Server; use App\Models\StandalonePostgresql; use App\Models\Team; use App\Models\TeamInvitation; @@ -65,9 +66,10 @@ public function handle() 'waitlist-invitation-link' => 'Waitlist Invitation Link', 'waitlist-confirmation' => 'Waitlist Confirmation', 'realusers-before-trial' => 'REAL - Registered Users Before Trial without Subscription', + 'realusers-server-lost-connection' => 'REAL - Server Lost Connection', ], ); - $emailsGathered = ['realusers-before-trial']; + $emailsGathered = ['realusers-before-trial','realusers-server-lost-connection']; if (!in_array($type, $emailsGathered)) { $this->email = text('Email Address to send to'); } @@ -199,6 +201,32 @@ public function handle() } } break; + case 'realusers-server-lost-connection': + $serverId = text('Server Id'); + $server = Server::find($serverId); + if (!$server) { + throw new Exception('Server not found'); + } + $admins = []; + $members = $server->team->members; + foreach ($members as $member) { + if ($member->isAdmin()) { + $admins[] = $member->email; + } + } + $this->info('Sending to ' . count($admins) . ' admins.'); + foreach ($admins as $admin) { + $this->info($admin); + } + $this->mail = new MailMessage(); + $this->mail->view('emails.server-lost-connection', [ + 'name' => $server->name, + ]); + $this->mail->subject('Action required: Server ' . $server->name . ' lost connection.'); + foreach ($admins as $email) { + $this->sendEmail($email); + } + break; } } private function sendEmail(string $email = null) diff --git a/resources/views/emails/server-lost-connection.blade.php b/resources/views/emails/server-lost-connection.blade.php new file mode 100644 index 000000000..67aa0816a --- /dev/null +++ b/resources/views/emails/server-lost-connection.blade.php @@ -0,0 +1,7 @@ + +Coolify Cloud cannot connect to your server ({{$name}}). Please check your server and make sure it is running. + +If you have any questions, please contact us. + + +