mirror of
https://github.com/nextcloud/server.git
synced 2026-04-27 01:00:20 -04:00
Merge pull request #49891 from nextcloud/refactor/settings/mail-settings-parameters
This commit is contained in:
commit
cd236c7941
2 changed files with 28 additions and 25 deletions
|
|
@ -44,34 +44,37 @@ class MailSettingsController extends Controller {
|
|||
|
||||
/**
|
||||
* Sets the email settings
|
||||
*
|
||||
* @param string $mail_domain
|
||||
* @param string $mail_from_address
|
||||
* @param string $mail_smtpmode
|
||||
* @param string $mail_smtpsecure
|
||||
* @param string $mail_smtphost
|
||||
* @param int $mail_smtpauth
|
||||
* @param string $mail_smtpport
|
||||
* @return DataResponse
|
||||
*/
|
||||
#[AuthorizedAdminSetting(settings: Overview::class)]
|
||||
#[PasswordConfirmationRequired]
|
||||
public function setMailSettings($mail_domain,
|
||||
$mail_from_address,
|
||||
$mail_smtpmode,
|
||||
$mail_smtpsecure,
|
||||
$mail_smtphost,
|
||||
$mail_smtpauth,
|
||||
$mail_smtpport,
|
||||
$mail_sendmailmode) {
|
||||
$params = get_defined_vars();
|
||||
$configs = [];
|
||||
foreach ($params as $key => $value) {
|
||||
public function setMailSettings(
|
||||
string $mail_domain,
|
||||
string $mail_from_address,
|
||||
string $mail_smtpmode,
|
||||
string $mail_smtpsecure,
|
||||
string $mail_smtphost,
|
||||
?string $mail_smtpauth,
|
||||
string $mail_smtpport,
|
||||
string $mail_sendmailmode,
|
||||
): DataResponse {
|
||||
$mail_smtpauth = $mail_smtpauth == '1';
|
||||
|
||||
$configs = [
|
||||
'mail_domain' => $mail_domain,
|
||||
'mail_from_address' => $mail_from_address,
|
||||
'mail_smtpmode' => $mail_smtpmode,
|
||||
'mail_smtpsecure' => $mail_smtpsecure,
|
||||
'mail_smtphost' => $mail_smtphost,
|
||||
'mail_smtpauth' => $mail_smtpauth,
|
||||
'mail_smtpport' => $mail_smtpport,
|
||||
'mail_sendmailmode' => $mail_sendmailmode,
|
||||
];
|
||||
foreach ($configs as $key => $value) {
|
||||
$configs[$key] = empty($value) ? null : $value;
|
||||
}
|
||||
|
||||
// Delete passwords from config in case no auth is specified
|
||||
if ($params['mail_smtpauth'] !== 1) {
|
||||
if (!$mail_smtpauth) {
|
||||
$configs['mail_smtpname'] = null;
|
||||
$configs['mail_smtppassword'] = null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class MailSettingsControllerTest extends \Test\TestCase {
|
|||
'mail_smtphost' => 'mx.nextcloud.org',
|
||||
'mail_smtpauth' => 1,
|
||||
'mail_smtpport' => '25',
|
||||
'mail_sendmailmode' => null,
|
||||
'mail_sendmailmode' => 'smtp',
|
||||
]],
|
||||
[[
|
||||
'mail_domain' => 'nextcloud.com',
|
||||
|
|
@ -82,7 +82,7 @@ class MailSettingsControllerTest extends \Test\TestCase {
|
|||
'mail_smtpport' => '25',
|
||||
'mail_smtpname' => null,
|
||||
'mail_smtppassword' => null,
|
||||
'mail_sendmailmode' => null,
|
||||
'mail_sendmailmode' => 'smtp',
|
||||
]]
|
||||
);
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ class MailSettingsControllerTest extends \Test\TestCase {
|
|||
'mx.nextcloud.org',
|
||||
1,
|
||||
'25',
|
||||
null
|
||||
'smtp'
|
||||
);
|
||||
$this->assertSame(Http::STATUS_OK, $response->getStatus());
|
||||
|
||||
|
|
@ -108,7 +108,7 @@ class MailSettingsControllerTest extends \Test\TestCase {
|
|||
'mx.nextcloud.org',
|
||||
0,
|
||||
'25',
|
||||
null
|
||||
'smtp'
|
||||
);
|
||||
$this->assertSame(Http::STATUS_OK, $response->getStatus());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue