This commit is contained in:
Andras Bacsai 2023-06-14 11:54:00 +02:00
parent 767824f2f7
commit 8f0cd69cd3
7 changed files with 34 additions and 40 deletions

View File

@ -4,7 +4,7 @@ namespace App\Http\Livewire\Notifications;
use App\Models\Server; use App\Models\Server;
use App\Models\Team; use App\Models\Team;
use App\Notifications\TestNotification; use App\Notifications\Notifications\TestNotification;
use Illuminate\Support\Facades\Notification; use Illuminate\Support\Facades\Notification;
use Livewire\Component; use Livewire\Component;

View File

@ -4,7 +4,7 @@ namespace App\Http\Livewire\Notifications;
use App\Models\InstanceSettings; use App\Models\InstanceSettings;
use App\Models\Team; use App\Models\Team;
use App\Notifications\TestNotification; use App\Notifications\Notifications\TestNotification;
use Illuminate\Support\Facades\Notification; use Illuminate\Support\Facades\Notification;
use Livewire\Component; use Livewire\Component;

View File

@ -11,7 +11,7 @@ class EmailChannel
public function send(SendsEmail $notifiable, Notification $notification): void public function send(SendsEmail $notifiable, Notification $notification): void
{ {
$this->bootConfigs($notifiable); $this->bootConfigs($notifiable);
$is_test_notification = $notification instanceof \App\Notifications\TestNotification; $is_test_notification = $notification instanceof \App\Notifications\Notifications\TestNotification;
if ($is_test_notification) { if ($is_test_notification) {
$bcc = $notifiable->routeNotificationForEmail('smtp_test_recipients'); $bcc = $notifiable->routeNotificationForEmail('smtp_test_recipients');

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Notifications; namespace App\Notifications\Notifications;
use App\Notifications\Channels\EmailChannel; use App\Notifications\Channels\EmailChannel;
use App\Notifications\Channels\DiscordChannel; use App\Notifications\Channels\DiscordChannel;
@ -29,6 +29,6 @@ class TestNotification extends Notification implements ShouldQueue
public function toDiscord(): string public function toDiscord(): string
{ {
return 'You have successfully received a test Discord notification from Coolify. 🥳 [Go to your dashboard](' . url('/') . ')'; return 'You have successfully received a test Discord notification from Coolify. 🥳 [Go to your dashboard](' . base_url() . ')';
} }
} }

View File

@ -11,7 +11,6 @@ use App\Models\InstanceSettings;
use App\Models\PrivateKey; use App\Models\PrivateKey;
use App\Models\Server; use App\Models\Server;
use App\Models\StandaloneDocker; use App\Models\StandaloneDocker;
use App\Models\Team;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Process; use Illuminate\Support\Facades\Process;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
@ -46,15 +45,6 @@ class ProductionSeeder extends Seeder
]); ]);
} }
// Add first Team if it doesn't exist
// if (Team::find(0) == null) {
// Team::create([
// 'id' => 0,
// 'name' => "Root's Team",
// 'personal_team' => true,
// ]);
// }
// Save SSH Keys for the Coolify Host // Save SSH Keys for the Coolify Host
$coolify_key_name = "id.root@host.docker.internal"; $coolify_key_name = "id.root@host.docker.internal";
$coolify_key = Storage::disk('ssh-keys')->get("{$coolify_key_name}"); $coolify_key = Storage::disk('ssh-keys')->get("{$coolify_key_name}");
@ -107,19 +97,22 @@ class ProductionSeeder extends Seeder
]); ]);
} }
try { try {
$ipv4 = Process::run('curl -4s https://ifconfig.io')->output();
$ipv4 = trim($ipv4);
$ipv4 = filter_var($ipv4, FILTER_VALIDATE_IP);
$settings = InstanceSettings::get(); $settings = InstanceSettings::get();
if (is_null($settings->public_ipv4) && $ipv4) { if (is_null($settings->public_ipv4)) {
$settings->update(['public_ipv4' => $ipv4]); $ipv4 = Process::run('curl -4s https://ifconfig.io')->output();
if ($ipv4) {
$ipv4 = trim($ipv4);
$ipv4 = filter_var($ipv4, FILTER_VALIDATE_IP);
$settings->update(['public_ipv4' => $ipv4]);
}
} }
$ipv6 = Process::run('curl -6s https://ifconfig.io')->output(); if (is_null($settings->public_ipv6)) {
$ipv6 = trim($ipv6); $ipv6 = Process::run('curl -6s https://ifconfig.io')->output();
$ipv6 = filter_var($ipv6, FILTER_VALIDATE_IP); if ($ipv6) {
$settings = InstanceSettings::get(); $ipv6 = trim($ipv6);
if (is_null($settings->public_ipv6) && $ipv6) { $ipv6 = filter_var($ipv6, FILTER_VALIDATE_IP);
$settings->update(['public_ipv6' => $ipv6]); $settings->update(['public_ipv6' => $ipv6]);
}
} }
} catch (\Exception $e) { } catch (\Exception $e) {
echo "Error: {$e->getMessage()}\n"; echo "Error: {$e->getMessage()}\n";

View File

@ -2,6 +2,7 @@
namespace Database\Seeders; namespace Database\Seeders;
use App\Actions\Proxy\InstallProxy;
use App\Data\ServerMetadata; use App\Data\ServerMetadata;
use App\Enums\ProxyStatus; use App\Enums\ProxyStatus;
use App\Enums\ProxyTypes; use App\Enums\ProxyTypes;

View File

@ -17,11 +17,11 @@
</x-forms.button> </x-forms.button>
@endif @endif
</div> </div>
<div class="flex flex-col w-96"> <div class="flex flex-col">
<x-forms.checkbox instantSave id="model.extra_attributes.smtp_active" label="Notification Enabled" /> <x-forms.checkbox instantSave id="model.extra_attributes.smtp_active" label="Notification Enabled" />
</div> </div>
<div class="flex gap-2"> <div class="flex flex-col gap-2 xl:flex-row">
<x-forms.input id="model.extra_attributes.smtp_recipients" <x-forms.input id="model.extra_attributes.smtp_recipients"
placeholder="If empty, all users will be notified in the team." placeholder="If empty, all users will be notified in the team."
helper="Email list to send the all notifications to, separated by comma." label="Recipient(s)" /> helper="Email list to send the all notifications to, separated by comma." label="Recipient(s)" />
@ -30,22 +30,22 @@
helper="Email list to send the test notification to, separated by comma." /> helper="Email list to send the test notification to, separated by comma." />
</div> </div>
<div class="flex flex-col gap-2 xl:flex-row"> <div class="flex flex-col gap-2 xl:flex-row">
<div class="flex flex-col w-96"> <x-forms.input required id="model.extra_attributes.smtp_host" helper="SMTP Hostname"
<x-forms.input required id="model.extra_attributes.smtp_host" helper="SMTP Hostname" placeholder="smtp.mailgun.org" label="Host" />
placeholder="smtp.mailgun.org" label="Host" /> <x-forms.input required id="model.extra_attributes.smtp_port" helper="SMTP Port" placeholder="587"
<x-forms.input required id="model.extra_attributes.smtp_port" helper="SMTP Port" placeholder="587" label="Port" />
label="Port" /> <x-forms.input helper="If SMTP through SSL, set it to 'tls'." placeholder="tls"
<x-forms.input helper="If SMTP through SSL, set it to 'tls'." placeholder="tls" id="model.extra_attributes.smtp_encryption" label="Encryption" />
id="model.extra_attributes.smtp_encryption" label="Encryption" /> </div>
</div> <div class="flex flex-col">
<div class="flex flex-col w-96"> <div class="flex flex-col gap-2 xl:flex-row">
<x-forms.input id="model.extra_attributes.smtp_username" helper="SMTP Username" label="Username" /> <x-forms.input id="model.extra_attributes.smtp_username" helper="SMTP Username" label="Username" />
<x-forms.input type="password" helper="SMTP Password" id="model.extra_attributes.smtp_password" <x-forms.input type="password" helper="SMTP Password" id="model.extra_attributes.smtp_password"
label="Password" /> label="Password" />
<x-forms.input id="model.extra_attributes.smtp_timeout" helper="Timeout value for sending emails."
label="Timeout" />
</div> </div>
<div class="flex flex-col w-96"> <x-forms.input id="model.extra_attributes.smtp_timeout" helper="Timeout value for sending emails."
label="Timeout" />
<div class="flex flex-col gap-2 xl:flex-row">
<x-forms.input required id="model.extra_attributes.smtp_from_name" helper="Name used in emails." <x-forms.input required id="model.extra_attributes.smtp_from_name" helper="Name used in emails."
label="From Name" /> label="From Name" />
<x-forms.input required id="model.extra_attributes.smtp_from_address" <x-forms.input required id="model.extra_attributes.smtp_from_address"