mirror of
https://github.com/PanCakeConnaisseur/auto_mail_accounts.git
synced 2024-06-08 00:42:14 +02:00
in case no email account are configured, let the hooks pass.
This commit is contained in:
parent
0be05349d3
commit
eb7cb1193a
|
@ -145,7 +145,7 @@ class UserHooks {
|
||||||
// immediately after the creation of the user.
|
// immediately after the creation of the user.
|
||||||
$firstAccountsMailAccount = $this->getUsersFirstMailAccount($user);
|
$firstAccountsMailAccount = $this->getUsersFirstMailAccount($user);
|
||||||
|
|
||||||
if ($feature === 'displayName') {
|
if (($firstAccountsMailAccount) and ($feature === 'displayName')) {
|
||||||
$firstAccountsMailAccount->setName($value);
|
$firstAccountsMailAccount->setName($value);
|
||||||
$this->accountService->save($firstAccountsMailAccount);
|
$this->accountService->save($firstAccountsMailAccount);
|
||||||
$this->logger->debug("Automatically changed sender name for mail account"
|
$this->logger->debug("Automatically changed sender name for mail account"
|
||||||
|
@ -160,11 +160,13 @@ class UserHooks {
|
||||||
// account is the first one, because it was automatically created
|
// account is the first one, because it was automatically created
|
||||||
// immediately after the creation of the user.
|
// immediately after the creation of the user.
|
||||||
$firstAccountsMailAccount = $this->getUsersFirstMailAccount($user);
|
$firstAccountsMailAccount = $this->getUsersFirstMailAccount($user);
|
||||||
|
if ($firstAccountsMailAccount) {
|
||||||
$firstAccountsMailAccount->setInboundPassword($this->encrypt($password));
|
$firstAccountsMailAccount->setInboundPassword($this->encrypt($password));
|
||||||
$firstAccountsMailAccount->setOutboundPassword($this->encrypt($password));
|
$firstAccountsMailAccount->setOutboundPassword($this->encrypt($password));
|
||||||
$this->accountService->save($firstAccountsMailAccount);
|
$this->accountService->save($firstAccountsMailAccount);
|
||||||
$this->logger->debug("Automatically changed password for mail account of uid "
|
$this->logger->debug("Automatically changed password for mail account of uid "
|
||||||
. $user->getUID() . ".", $this->logContext);
|
. $user->getUID() . ".", $this->logContext);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,10 +177,14 @@ class UserHooks {
|
||||||
|
|
||||||
private function getUsersFirstMailAccount(\OC\User\User $user) {
|
private function getUsersFirstMailAccount(\OC\User\User $user) {
|
||||||
$accounts = $this->accountService->findByUserId($user->getUID());
|
$accounts = $this->accountService->findByUserId($user->getUID());
|
||||||
|
if ($accounts) {
|
||||||
uksort($accounts, function ($a, $b) {
|
uksort($accounts, function ($a, $b) {
|
||||||
return ($a['account']['id'] < $b['account']['id']) ? -1 : 1;
|
return ($a['account']['id'] < $b['account']['id']) ? -1 : 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
return $accounts[0]->getMailAccount();
|
return $accounts[0]->getMailAccount();
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue