mirror of
https://github.com/cupcakearmy/coolify.git
synced 2024-10-22 16:14:22 +02:00
fixes
This commit is contained in:
parent
0aa816b4f2
commit
6e094eaf42
@ -13,11 +13,11 @@ class DiscordSettings extends Component
|
|||||||
public Team|Server $model;
|
public Team|Server $model;
|
||||||
|
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
'model.smtp_attributes.discord_active' => 'nullable|boolean',
|
'model.extra_attributes.discord_active' => 'nullable|boolean',
|
||||||
'model.smtp_attributes.discord_webhook' => 'required|url',
|
'model.extra_attributes.discord_webhook' => 'required|url',
|
||||||
];
|
];
|
||||||
protected $validationAttributes = [
|
protected $validationAttributes = [
|
||||||
'model.smtp_attributes.discord_webhook' => 'Discord Webhook',
|
'model.extra_attributes.discord_webhook' => 'Discord Webhook',
|
||||||
];
|
];
|
||||||
public function mount($model)
|
public function mount($model)
|
||||||
{
|
{
|
||||||
@ -28,8 +28,8 @@ public function instantSave()
|
|||||||
try {
|
try {
|
||||||
$this->submit();
|
$this->submit();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->model->smtp_attributes->discord_active = false;
|
$this->model->extra_attributes->discord_active = false;
|
||||||
$this->addError('model.smtp_attributes.discord_webhook', $e->getMessage());
|
$this->validate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private function saveModel()
|
private function saveModel()
|
||||||
|
@ -13,27 +13,27 @@ class EmailSettings extends Component
|
|||||||
public Team|Server $model;
|
public Team|Server $model;
|
||||||
|
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
'model.smtp_attributes.smtp_active' => 'nullable|boolean',
|
'model.extra_attributes.smtp_active' => 'nullable|boolean',
|
||||||
'model.smtp_attributes.from_address' => 'required',
|
'model.extra_attributes.from_address' => 'required|email',
|
||||||
'model.smtp_attributes.from_name' => 'required',
|
'model.extra_attributes.from_name' => 'required',
|
||||||
'model.smtp_attributes.recipients' => 'required',
|
'model.extra_attributes.recipients' => 'required',
|
||||||
'model.smtp_attributes.smtp_host' => 'required',
|
'model.extra_attributes.smtp_host' => 'required',
|
||||||
'model.smtp_attributes.smtp_port' => 'required',
|
'model.extra_attributes.smtp_port' => 'required',
|
||||||
'model.smtp_attributes.smtp_encryption' => 'nullable',
|
'model.extra_attributes.smtp_encryption' => 'nullable',
|
||||||
'model.smtp_attributes.smtp_username' => 'nullable',
|
'model.extra_attributes.smtp_username' => 'nullable',
|
||||||
'model.smtp_attributes.smtp_password' => 'nullable',
|
'model.extra_attributes.smtp_password' => 'nullable',
|
||||||
'model.smtp_attributes.smtp_timeout' => 'nullable',
|
'model.extra_attributes.smtp_timeout' => 'nullable',
|
||||||
'model.smtp_attributes.test_address' => 'nullable',
|
'model.extra_attributes.test_notification_email' => 'nullable|email',
|
||||||
];
|
];
|
||||||
protected $validationAttributes = [
|
protected $validationAttributes = [
|
||||||
'model.smtp_attributes.from_address' => 'From Address',
|
'model.extra_attributes.from_address' => 'From Address',
|
||||||
'model.smtp_attributes.from_name' => 'From Name',
|
'model.extra_attributes.from_name' => 'From Name',
|
||||||
'model.smtp_attributes.recipients' => 'Recipients',
|
'model.extra_attributes.recipients' => 'Recipients',
|
||||||
'model.smtp_attributes.smtp_host' => 'Host',
|
'model.extra_attributes.smtp_host' => 'Host',
|
||||||
'model.smtp_attributes.smtp_port' => 'Port',
|
'model.extra_attributes.smtp_port' => 'Port',
|
||||||
'model.smtp_attributes.smtp_encryption' => 'Encryption',
|
'model.extra_attributes.smtp_encryption' => 'Encryption',
|
||||||
'model.smtp_attributes.smtp_username' => 'Username',
|
'model.extra_attributes.smtp_username' => 'Username',
|
||||||
'model.smtp_attributes.smtp_password' => 'Password',
|
'model.extra_attributes.smtp_password' => 'Password',
|
||||||
];
|
];
|
||||||
public function mount($model)
|
public function mount($model)
|
||||||
{
|
{
|
||||||
@ -54,6 +54,11 @@ private function saveModel()
|
|||||||
}
|
}
|
||||||
public function instantSave()
|
public function instantSave()
|
||||||
{
|
{
|
||||||
$this->saveModel();
|
try {
|
||||||
|
$this->submit();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->model->extra_attributes->smtp_active = false;
|
||||||
|
$this->validate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,22 +23,16 @@ protected static function booted()
|
|||||||
'team_id',
|
'team_id',
|
||||||
'private_key_id',
|
'private_key_id',
|
||||||
'extra_attributes',
|
'extra_attributes',
|
||||||
'smtp_attributes',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
public $casts = [
|
public $casts = [
|
||||||
'extra_attributes' => SchemalessAttributes::class,
|
'extra_attributes' => SchemalessAttributes::class,
|
||||||
'smtp_attributes' => SchemalessAttributes::class,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
public function scopeWithExtraAttributes(): Builder
|
public function scopeWithExtraAttributes(): Builder
|
||||||
{
|
{
|
||||||
return $this->extra_attributes->modelScope();
|
return $this->extra_attributes->modelScope();
|
||||||
}
|
}
|
||||||
public function scopeWithSmtpAttributes(): Builder
|
|
||||||
{
|
|
||||||
return $this->smtp_attributes->modelScope();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function standaloneDockers()
|
public function standaloneDockers()
|
||||||
{
|
{
|
||||||
|
@ -13,30 +13,32 @@ class Team extends BaseModel implements SendsDiscord, SendsEmail
|
|||||||
use Notifiable;
|
use Notifiable;
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'smtp_attributes' => SchemalessAttributes::class,
|
'extra_attributes' => SchemalessAttributes::class,
|
||||||
'personal_team' => 'boolean',
|
'personal_team' => 'boolean',
|
||||||
];
|
];
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'id',
|
'id',
|
||||||
'name',
|
'name',
|
||||||
'personal_team',
|
'personal_team',
|
||||||
'smtp_attributes',
|
'extra_attributes',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function routeNotificationForDiscord()
|
public function routeNotificationForDiscord()
|
||||||
{
|
{
|
||||||
return $this->smtp_attributes->get('discord_webhook');
|
return $this->extra_attributes->get('discord_webhook');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function routeNotificationForEmail(string $attribute = 'recipients')
|
public function routeNotificationForEmail(string $attribute = 'recipients')
|
||||||
{
|
{
|
||||||
$recipients = $this->smtp_attributes->get($attribute, '');
|
$recipients = $this->extra_attributes->get($attribute, '');
|
||||||
return explode(PHP_EOL, $recipients);
|
if (is_null($recipients) || $recipients === '') {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return explode(',', $recipients);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scopeWithExtraAttributes(): Builder
|
public function scopeWithExtraAttributes(): Builder
|
||||||
{
|
{
|
||||||
return $this->smtp_attributes->modelScope();
|
return $this->extra_attributes->modelScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function projects()
|
public function projects()
|
||||||
|
@ -15,8 +15,8 @@ public function send(SendsEmail $notifiable, Notification $notification): void
|
|||||||
{
|
{
|
||||||
$this->bootConfigs($notifiable);
|
$this->bootConfigs($notifiable);
|
||||||
if ($notification instanceof \App\Notifications\TestNotification) {
|
if ($notification instanceof \App\Notifications\TestNotification) {
|
||||||
$bcc = $notifiable->routeNotificationForEmail('test_address');
|
$bcc = $notifiable->routeNotificationForEmail('test_notification_email');
|
||||||
if (count($bcc) === 1) {
|
if (count($bcc) === 0) {
|
||||||
$bcc = $notifiable->routeNotificationForEmail();
|
$bcc = $notifiable->routeNotificationForEmail();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -29,8 +29,8 @@ public function send(SendsEmail $notifiable, Notification $notification): void
|
|||||||
[],
|
[],
|
||||||
fn (Message $message) => $message
|
fn (Message $message) => $message
|
||||||
->from(
|
->from(
|
||||||
$notifiable->smtp_attributes?->get('from_address'),
|
$notifiable->extra_attributes?->get('from_address'),
|
||||||
$notifiable->smtp_attributes?->get('from_name')
|
$notifiable->extra_attributes?->get('from_name')
|
||||||
)
|
)
|
||||||
->cc($bcc)
|
->cc($bcc)
|
||||||
->bcc($bcc)
|
->bcc($bcc)
|
||||||
@ -44,12 +44,12 @@ private function bootConfigs($notifiable): void
|
|||||||
config()->set('mail.default', 'smtp');
|
config()->set('mail.default', 'smtp');
|
||||||
config()->set('mail.mailers.smtp', [
|
config()->set('mail.mailers.smtp', [
|
||||||
"transport" => "smtp",
|
"transport" => "smtp",
|
||||||
"host" => $notifiable->smtp_attributes?->get('smtp_host'),
|
"host" => $notifiable->extra_attributes?->get('smtp_host'),
|
||||||
"port" => $notifiable->smtp_attributes?->get('smtp_port'),
|
"port" => $notifiable->extra_attributes?->get('smtp_port'),
|
||||||
"encryption" => $notifiable->smtp_attributes?->get('smtp_encryption'),
|
"encryption" => $notifiable->extra_attributes?->get('smtp_encryption'),
|
||||||
"username" => $notifiable->smtp_attributes?->get('smtp_username'),
|
"username" => $notifiable->extra_attributes?->get('smtp_username'),
|
||||||
"password" => $notifiable->smtp_attributes?->get('smtp_password'),
|
"password" => $notifiable->extra_attributes?->get('smtp_password'),
|
||||||
"timeout" => $notifiable->smtp_attributes?->get('smtp_timeout'),
|
"timeout" => $notifiable->extra_attributes?->get('smtp_timeout'),
|
||||||
"local_domain" => null,
|
"local_domain" => null,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,8 @@ public function __construct()
|
|||||||
public function via(object $notifiable): array
|
public function via(object $notifiable): array
|
||||||
{
|
{
|
||||||
$channels = [];
|
$channels = [];
|
||||||
$notifiable->smtp_attributes?->get('smtp_active') && $channels[] = EmailChannel::class;
|
$notifiable->extra_attributes?->get('smtp_active') && $channels[] = EmailChannel::class;
|
||||||
$notifiable->smtp_attributes?->get('discord_active') && $channels[] = DiscordChannel::class;
|
$notifiable->extra_attributes?->get('discord_active') && $channels[] = DiscordChannel::class;
|
||||||
return $channels;
|
return $channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ public function up(): void
|
|||||||
$table->string('uuid')->unique();
|
$table->string('uuid')->unique();
|
||||||
$table->string('name');
|
$table->string('name');
|
||||||
$table->boolean('personal_team')->default(false);
|
$table->boolean('personal_team')->default(false);
|
||||||
$table->schemalessAttributes('smtp_attributes');
|
$table->schemalessAttributes('extra_attributes');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ public function up(): void
|
|||||||
$table->foreignId('team_id');
|
$table->foreignId('team_id');
|
||||||
$table->foreignId('private_key_id');
|
$table->foreignId('private_key_id');
|
||||||
$table->schemalessAttributes('extra_attributes');
|
$table->schemalessAttributes('extra_attributes');
|
||||||
$table->schemalessAttributes('smtp_attributes');
|
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,10 @@
|
|||||||
</x-forms.button>
|
</x-forms.button>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col gap-2 xl:flex-row w-96">
|
<div class="flex flex-col gap-2 xl:flex-row w-96">
|
||||||
<x-forms.checkbox instantSave id="model.smtp_attributes.discord_active" label="Notification Enabled" />
|
<x-forms.checkbox instantSave id="model.extra_attributes.discord_active" label="Notification Enabled" />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col gap-2 xl:flex-row w-96">
|
<div class="flex flex-col gap-2 xl:flex-row w-96">
|
||||||
<x-forms.input required id="model.smtp_attributes.discord_webhook" label="Webhook" />
|
<x-forms.input required id="model.extra_attributes.discord_webhook" label="Webhook" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
|
@ -7,28 +7,29 @@
|
|||||||
</x-forms.button>
|
</x-forms.button>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col w-96">
|
<div class="flex flex-col w-96">
|
||||||
<x-forms.checkbox instantSave id="model.smtp_attributes.smtp_active" label="Notification Enabled" />
|
<x-forms.checkbox instantSave id="model.extra_attributes.smtp_active" label="Notification Enabled" />
|
||||||
</div>
|
</div>
|
||||||
|
<x-forms.input id="model.extra_attributes.test_notification_email" label="Test Notification Email" />
|
||||||
<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">
|
<div class="flex flex-col w-96">
|
||||||
<x-forms.textarea required id="model.smtp_attributes.recipients" helper="E-mails, one per line"
|
<x-forms.input required id="model.extra_attributes.recipients" helper="Emails separated by comma"
|
||||||
label="Recipients" />
|
label="Recipients" />
|
||||||
</div>
|
</div>
|
||||||
</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">
|
<div class="flex flex-col w-96">
|
||||||
<x-forms.input required id="model.smtp_attributes.smtp_host" label="Host" />
|
<x-forms.input required id="model.extra_attributes.smtp_host" label="Host" />
|
||||||
<x-forms.input required id="model.smtp_attributes.smtp_port" label="Port" />
|
<x-forms.input required id="model.extra_attributes.smtp_port" label="Port" />
|
||||||
<x-forms.input id="model.smtp_attributes.smtp_encryption" label="Encryption" />
|
<x-forms.input id="model.extra_attributes.smtp_encryption" label="Encryption" />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col w-96">
|
<div class="flex flex-col w-96">
|
||||||
<x-forms.input id="model.smtp_attributes.smtp_username" label="Username" />
|
<x-forms.input id="model.extra_attributes.smtp_username" label="Username" />
|
||||||
<x-forms.input id="model.smtp_attributes.smtp_password" label="Password" />
|
<x-forms.input id="model.extra_attributes.smtp_password" label="Password" />
|
||||||
<x-forms.input id="model.smtp_attributes.smtp_timeout" label="Timeout" />
|
<x-forms.input id="model.extra_attributes.smtp_timeout" label="Timeout" />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col w-96">
|
<div class="flex flex-col w-96">
|
||||||
<x-forms.input required id="model.smtp_attributes.from_address" label="From Address" />
|
<x-forms.input required id="model.extra_attributes.from_address" label="From Address" />
|
||||||
<x-forms.input required id="model.smtp_attributes.from_name" label="From Name" />
|
<x-forms.input required id="model.extra_attributes.from_name" label="From Name" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
Loading…
Reference in New Issue
Block a user