This commit is contained in:
Andras Bacsai 2023-07-28 11:49:25 +02:00
parent 4a20abcbfa
commit 766fa85c4c
3 changed files with 40 additions and 34 deletions

View File

@ -55,17 +55,23 @@ public function copyFromInstanceSettings()
{
$settings = InstanceSettings::get();
if ($settings->smtp_enabled) {
$this->model->smtp_enabled = true;
$this->model->smtp_from_address = $settings->smtp_from_address;
$this->model->smtp_from_name = $settings->smtp_from_name;
$this->model->smtp_recipients = $settings->smtp_recipients;
$this->model->smtp_host = $settings->smtp_host;
$this->model->smtp_port = $settings->smtp_port;
$this->model->smtp_encryption = $settings->smtp_encryption;
$this->model->smtp_username = $settings->smtp_username;
$this->model->smtp_password = $settings->smtp_password;
$this->model->smtp_timeout = $settings->smtp_timeout;
$this->saveModel();
$team = auth()->user()->currentTeam();
$team->smtp_enabled = true;
$team->smtp_from_address = $settings->smtp_from_address;
$team->smtp_from_name = $settings->smtp_from_name;
$team->smtp_recipients = $settings->smtp_recipients;
$team->smtp_host = $settings->smtp_host;
$team->smtp_port = $settings->smtp_port;
$team->smtp_encryption = $settings->smtp_encryption;
$team->smtp_username = $settings->smtp_username;
$team->smtp_password = $settings->smtp_password;
$team->smtp_timeout = $settings->smtp_timeout;
$team->save();
$this->decrypt();
if (is_a($team, Team::class)) {
session(['currentTeam' => $this->model]);
}
$this->emit('success', 'Settings saved.');
} else {
$this->emit('error', 'Instance SMTP settings are not enabled.');
}

View File

@ -26,10 +26,8 @@ public function routeNotificationForDiscord()
public function getRecepients($notification)
{
$recipients = data_get($notification,'emails',null);
ray($recipients);
if (is_null($recipients)) {
$recipients = $this->members()->pluck('email')->toArray();
ray($recipients);
return $recipients;
}
return explode(',', $recipients);

View File

@ -31,27 +31,29 @@ class="text-white normal-case btn btn-xs no-animation btn-primary">
<div class="w-48">
<x-forms.checkbox instantSave id="model.smtp_enabled" label="Notification Enabled" />
</div>
<div class="flex flex-col gap-2 xl:flex-row">
<x-forms.input id="model.smtp_recipients" placeholder="If empty, all users will be notified in the team."
helper="Email list to send the all notifications to, separated by comma." label="Recipients" />
</div>
<div class="flex flex-col gap-2 xl:flex-row">
<x-forms.input required id="model.smtp_host" helper="SMTP Hostname" placeholder="smtp.mailgun.org"
label="Host" />
<x-forms.input required id="model.smtp_port" helper="SMTP Port" placeholder="587" label="Port" />
<x-forms.input helper="If SMTP through SSL, set it to 'tls'." placeholder="tls" id="model.smtp_encryption"
label="Encryption" />
</div>
<div class="flex flex-col gap-2 xl:flex-row">
<x-forms.input id="model.smtp_username" label="SMTP Username" />
<x-forms.input type="password" id="model.smtp_password" label="SMTP Password" />
<x-forms.input id="model.smtp_timeout" helper="Timeout value for sending emails." label="Timeout" />
</div>
<div class="flex flex-col gap-2 xl:flex-row">
<x-forms.input required id="model.smtp_from_name" helper="Name used in emails." label="From Name" />
<x-forms.input required id="model.smtp_from_address" helper="Email address used in emails."
label="From Address" />
<div class="flex flex-col gap-4">
<div class="flex flex-col gap-2 xl:flex-row">
<x-forms.input id="model.smtp_recipients"
placeholder="If empty, all users will be notified in the team."
helper="Email list to send the all notifications to, separated by comma." label="Recipients" />
</div>
<div class="flex flex-col gap-2 xl:flex-row">
<x-forms.input required id="model.smtp_host" helper="SMTP Hostname" placeholder="smtp.mailgun.org"
label="Host" />
<x-forms.input required id="model.smtp_port" helper="SMTP Port" placeholder="587" label="Port" />
<x-forms.input helper="If SMTP through SSL, set it to 'tls'." placeholder="tls"
id="model.smtp_encryption" label="Encryption" />
</div>
<div class="flex flex-col gap-2 xl:flex-row">
<x-forms.input id="model.smtp_username" label="SMTP Username" />
<x-forms.input type="password" id="model.smtp_password" label="SMTP Password" />
<x-forms.input id="model.smtp_timeout" helper="Timeout value for sending emails." label="Timeout" />
</div>
<div class="flex flex-col gap-2 xl:flex-row">
<x-forms.input required id="model.smtp_from_name" helper="Name used in emails." label="From Name" />
<x-forms.input required id="model.smtp_from_address" helper="Email address used in emails."
label="From Address" />
</div>
</div>
</form>
@if (data_get($model, 'smtp_enabled'))