Skip to content

Commit

Permalink
refactor(settings): Use parameters explicitly when setting mail settings
Browse files Browse the repository at this point in the history
Signed-off-by: provokateurin <[email protected]>
  • Loading branch information
provokateurin committed Dec 17, 2024
1 parent f16d047 commit 6a415b8
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions apps/settings/lib/Controller/MailSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,32 @@ public function __construct(
*/
#[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,
int $mail_smtpauth,
string $mail_smtpport,
string $mail_sendmailmode,
) {
$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 ($configs['mail_smtpauth'] !== 1) {
$configs['mail_smtpname'] = null;
$configs['mail_smtppassword'] = null;
}
Expand Down

0 comments on commit 6a415b8

Please sign in to comment.