fix: smtp view
This commit is contained in:
@@ -46,9 +46,6 @@ class DiscordSettings extends Component
|
|||||||
public function saveModel()
|
public function saveModel()
|
||||||
{
|
{
|
||||||
$this->team->save();
|
$this->team->save();
|
||||||
if (is_a($this->team, Team::class)) {
|
|
||||||
refreshSession();
|
|
||||||
}
|
|
||||||
$this->emit('success', 'Settings saved.');
|
$this->emit('success', 'Settings saved.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,9 +110,6 @@ class EmailSettings extends Component
|
|||||||
public function saveModel()
|
public function saveModel()
|
||||||
{
|
{
|
||||||
$this->team->save();
|
$this->team->save();
|
||||||
if (is_a($this->team, Team::class)) {
|
|
||||||
refreshSession();
|
|
||||||
}
|
|
||||||
$this->emit('success', 'Settings saved.');
|
$this->emit('success', 'Settings saved.');
|
||||||
}
|
}
|
||||||
public function submit()
|
public function submit()
|
||||||
@@ -141,10 +138,11 @@ class EmailSettings extends Component
|
|||||||
try {
|
try {
|
||||||
$this->resetErrorBag();
|
$this->resetErrorBag();
|
||||||
$this->validate([
|
$this->validate([
|
||||||
|
'team.smtp_from_address' => 'required|email',
|
||||||
|
'team.smtp_from_name' => 'required',
|
||||||
'team.resend_api_key' => 'required'
|
'team.resend_api_key' => 'required'
|
||||||
]);
|
]);
|
||||||
$this->team->save();
|
$this->team->save();
|
||||||
refreshSession();
|
|
||||||
$this->emit('success', 'Settings saved successfully.');
|
$this->emit('success', 'Settings saved successfully.');
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$this->team->resend_enabled = false;
|
$this->team->resend_enabled = false;
|
||||||
|
|||||||
@@ -52,9 +52,6 @@ class TelegramSettings extends Component
|
|||||||
public function saveModel()
|
public function saveModel()
|
||||||
{
|
{
|
||||||
$this->team->save();
|
$this->team->save();
|
||||||
if (is_a($this->team, Team::class)) {
|
|
||||||
refreshSession();
|
|
||||||
}
|
|
||||||
$this->emit('success', 'Settings saved.');
|
$this->emit('success', 'Settings saved.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ class Form extends Component
|
|||||||
$this->validate();
|
$this->validate();
|
||||||
try {
|
try {
|
||||||
$this->team->save();
|
$this->team->save();
|
||||||
refreshSession();
|
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return general_error_handler($e, $this);
|
return general_error_handler($e, $this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,13 @@ class Team extends Model implements SendsDiscord, SendsEmail
|
|||||||
'resend_api_key' => 'encrypted',
|
'resend_api_key' => 'encrypted',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected static function booted()
|
||||||
|
{
|
||||||
|
static::saved(function () {
|
||||||
|
refreshSession();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public function routeNotificationForDiscord()
|
public function routeNotificationForDiscord()
|
||||||
{
|
{
|
||||||
return data_get($this, 'discord_webhook_url', null);
|
return data_get($this, 'discord_webhook_url', null);
|
||||||
|
|||||||
@@ -62,7 +62,11 @@ function showBoarding(): bool
|
|||||||
function refreshSession(?Team $team = null): void
|
function refreshSession(?Team $team = null): void
|
||||||
{
|
{
|
||||||
if (!$team) {
|
if (!$team) {
|
||||||
$team = User::find(auth()->user()->id)->teams->first();
|
if (auth()->user()->currentTeam()) {
|
||||||
|
$team = Team::find(auth()->user()->currentTeam()->id);
|
||||||
|
} else {
|
||||||
|
$team = User::find(auth()->user()->id)->teams->first();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Cache::forget('team:' . auth()->user()->id);
|
Cache::forget('team:' . auth()->user()->id);
|
||||||
Cache::remember('team:' . auth()->user()->id, 3600, function() use ($team) {
|
Cache::remember('team:' . auth()->user()->id, 3600, function() use ($team) {
|
||||||
|
|||||||
@@ -21,7 +21,8 @@
|
|||||||
Copy from Instance Settings
|
Copy from Instance Settings
|
||||||
</x-forms.button>
|
</x-forms.button>
|
||||||
@endif
|
@endif
|
||||||
@if (isEmailEnabled($team) && auth()->user()->isAdminFromSession())
|
@if (isEmailEnabled($team) &&
|
||||||
|
auth()->user()->isAdminFromSession())
|
||||||
<x-forms.button onclick="sendTestEmail.showModal()"
|
<x-forms.button onclick="sendTestEmail.showModal()"
|
||||||
class="text-white normal-case btn btn-xs no-animation btn-primary">
|
class="text-white normal-case btn btn-xs no-animation btn-primary">
|
||||||
Send Test Email
|
Send Test Email
|
||||||
@@ -51,61 +52,52 @@
|
|||||||
</x-forms.button>
|
</x-forms.button>
|
||||||
</form>
|
</form>
|
||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
<details class="border rounded collapse border-coolgray-500 collapse-arrow ">
|
<div class="p-4 border border-coolgray-500">
|
||||||
<summary class="text-xl collapse-title">
|
<h3>SMTP Server</h3>
|
||||||
<div>SMTP Server</div>
|
<div class="w-32">
|
||||||
<div class="w-32">
|
<x-forms.checkbox instantSave id="team.smtp_enabled" label="Enabled" />
|
||||||
<x-forms.checkbox instantSave id="team.smtp_enabled" label="Enabled" />
|
|
||||||
</div>
|
|
||||||
</summary>
|
|
||||||
<div class="collapse-content">
|
|
||||||
<form wire:submit.prevent='submit' class="flex flex-col">
|
|
||||||
<div class="flex flex-col gap-4">
|
|
||||||
<div class="flex flex-col w-full gap-2 xl:flex-row">
|
|
||||||
<x-forms.input required id="team.smtp_host" placeholder="smtp.mailgun.org"
|
|
||||||
label="Host" />
|
|
||||||
<x-forms.input required id="team.smtp_port" placeholder="587" label="Port" />
|
|
||||||
<x-forms.input id="team.smtp_encryption" helper="If SMTP uses SSL, set it to 'tls'."
|
|
||||||
placeholder="tls" label="Encryption" />
|
|
||||||
</div>
|
|
||||||
<div class="flex flex-col w-full gap-2 xl:flex-row">
|
|
||||||
<x-forms.input id="team.smtp_username" label="SMTP Username" />
|
|
||||||
<x-forms.input id="team.smtp_password" type="password" label="SMTP Password" />
|
|
||||||
<x-forms.input id="team.smtp_timeout" helper="Timeout value for sending emails."
|
|
||||||
label="Timeout" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="flex justify-end gap-4 pt-6">
|
|
||||||
<x-forms.button type="submit">
|
|
||||||
Save
|
|
||||||
</x-forms.button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</details>
|
<form wire:submit.prevent='submit' class="flex flex-col">
|
||||||
<details class="border rounded collapse border-coolgray-500 collapse-arrow">
|
<div class="flex flex-col gap-4">
|
||||||
<summary class="text-xl collapse-title">
|
<div class="flex flex-col w-full gap-2 xl:flex-row">
|
||||||
<div>Resend</div>
|
<x-forms.input required id="team.smtp_host" placeholder="smtp.mailgun.org" label="Host" />
|
||||||
<div class="w-32">
|
<x-forms.input required id="team.smtp_port" placeholder="587" label="Port" />
|
||||||
<x-forms.checkbox instantSave='instantSaveResend' id="team.resend_enabled" label="Enabled" />
|
<x-forms.input id="team.smtp_encryption" helper="If SMTP uses SSL, set it to 'tls'."
|
||||||
|
placeholder="tls" label="Encryption" />
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-col w-full gap-2 xl:flex-row">
|
||||||
|
<x-forms.input id="team.smtp_username" label="SMTP Username" />
|
||||||
|
<x-forms.input id="team.smtp_password" type="password" label="SMTP Password" />
|
||||||
|
<x-forms.input id="team.smtp_timeout" helper="Timeout value for sending emails."
|
||||||
|
label="Timeout" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</summary>
|
<div class="flex justify-end gap-4 pt-6">
|
||||||
<div class="collapse-content">
|
<x-forms.button type="submit">
|
||||||
<form wire:submit.prevent='submitResend' class="flex flex-col">
|
Save
|
||||||
<div class="flex flex-col gap-4">
|
</x-forms.button>
|
||||||
<div class="flex flex-col w-full gap-2 xl:flex-row">
|
</div>
|
||||||
<x-forms.input required type="password" id="team.resend_api_key" placeholder="API key"
|
</form>
|
||||||
label="API Key" />
|
</div>
|
||||||
</div>
|
<div class="p-4 border border-coolgray-500">
|
||||||
</div>
|
<h3>Resend</h3>
|
||||||
<div class="flex justify-end gap-4 pt-6">
|
<div class="w-32">
|
||||||
<x-forms.button type="submit">
|
<x-forms.checkbox instantSave='instantSaveResend' id="team.resend_enabled" label="Enabled" />
|
||||||
Save
|
|
||||||
</x-forms.button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</details>
|
<form wire:submit.prevent='submitResend' class="flex flex-col">
|
||||||
|
<div class="flex flex-col gap-4">
|
||||||
|
<div class="flex flex-col w-full gap-2 xl:flex-row">
|
||||||
|
<x-forms.input required type="password" id="team.resend_api_key" placeholder="API key"
|
||||||
|
label="API Key" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex justify-end gap-4 pt-6">
|
||||||
|
<x-forms.button type="submit">
|
||||||
|
Save
|
||||||
|
</x-forms.button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
@if (isEmailEnabled($team) || data_get($team, 'use_instance_email_settings'))
|
@if (isEmailEnabled($team) || data_get($team, 'use_instance_email_settings'))
|
||||||
|
|||||||
Reference in New Issue
Block a user