mirror of
https://github.com/PanCakeConnaisseur/auto_mail_accounts.git
synced 2024-05-04 06:33:11 +02:00
Fix deletion of users when no mail account is present
Instead of catching a null reference for non-existing mail accounts, it seems to be easier to only get the mail acccount when we actually want to do something with it. Since we are only intersted in the change of the display name, the retreival of the user account has been moved to that if-branch. This also seems more like a Nextcloud bug, since it fails on errors of hooks.
This commit is contained in:
parent
d66507d818
commit
61e3c854e6
|
@ -140,12 +140,11 @@ class UserHooks {
|
||||||
|
|
||||||
private function changeUserCallbackFunction() {
|
private function changeUserCallbackFunction() {
|
||||||
return function (\OC\User\User $user, string $feature, string $value) {
|
return function (\OC\User\User $user, string $feature, string $value) {
|
||||||
// The assumption is made that the automatically created mail
|
|
||||||
// account is the first one, because it was automatically created
|
|
||||||
// immediately after the creation of the user.
|
|
||||||
$firstAccountsMailAccount = $this->getUsersFirstMailAccount($user);
|
|
||||||
|
|
||||||
if ($feature === 'displayName') {
|
if ($feature === 'displayName') {
|
||||||
|
// The assumption is made that the automatically created mail
|
||||||
|
// account is the first one, because it was automatically created
|
||||||
|
// immediately after the creation of the user.
|
||||||
|
$firstAccountsMailAccount = $this->getUsersFirstMailAccount($user);
|
||||||
$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"
|
||||||
|
|
Loading…
Reference in a new issue