Browse Source

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.
master
Alexey Abel 3 years ago
parent
commit
61e3c854e6
  1. 9
      lib/Hooks/UserHooks.php

9
lib/Hooks/UserHooks.php

@ -140,12 +140,11 @@ class UserHooks {
private function changeUserCallbackFunction() {
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') {
// 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);
$this->accountService->save($firstAccountsMailAccount);
$this->logger->debug("Automatically changed sender name for mail account"

Loading…
Cancel
Save