diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2021-05-12 13:58:37 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2021-05-12 22:55:28 +0200 |
commit | 2ee34ff76c3fb847f93662007330457a5427babb (patch) | |
tree | ede1ec7f5be6172db3c7248640ea074a1ab93dc9 | |
parent | 9b36252de0f7cc6b971c8a23524495e38f35dcf2 (diff) | |
download | nextcloud-server-2ee34ff76c3fb847f93662007330457a5427babb.tar.gz nextcloud-server-2ee34ff76c3fb847f93662007330457a5427babb.zip |
Repair job to use public AccoutManager API
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
-rw-r--r-- | lib/private/Repair/NC21/ValidatePhoneNumber.php | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/lib/private/Repair/NC21/ValidatePhoneNumber.php b/lib/private/Repair/NC21/ValidatePhoneNumber.php index 995c38602f3..ca79786f909 100644 --- a/lib/private/Repair/NC21/ValidatePhoneNumber.php +++ b/lib/private/Repair/NC21/ValidatePhoneNumber.php @@ -26,7 +26,6 @@ declare(strict_types=1); namespace OC\Repair\NC21; -use OC\Accounts\AccountManager; use OCP\Accounts\IAccountManager; use OCP\IConfig; use OCP\IUser; @@ -40,11 +39,11 @@ class ValidatePhoneNumber implements IRepairStep { protected $config; /** @var IUserManager */ protected $userManager; - /** @var AccountManager */ + /** @var IAccountManager */ private $accountManager; public function __construct(IUserManager $userManager, - AccountManager $accountManager, + IAccountManager $accountManager, IConfig $config) { $this->config = $config; $this->userManager = $userManager; @@ -55,10 +54,6 @@ class ValidatePhoneNumber implements IRepairStep { return 'Validate the phone number and store it in a known format for search'; } - private function shouldRun(): bool { - return true; - } - public function run(IOutput $output): void { if ($this->config->getSystemValueString('default_phone_region', '') === '') { throw new \Exception('Can not validate phone numbers without `default_phone_region` being set in the config file'); @@ -68,13 +63,16 @@ class ValidatePhoneNumber implements IRepairStep { $numRemoved = 0; $this->userManager->callForSeenUsers(function (IUser $user) use (&$numUpdated, &$numRemoved) { - $account = $this->accountManager->getUser($user); + $account = $this->accountManager->getAccount($user); + $property = $account->getProperty(IAccountManager::PROPERTY_PHONE); - if ($account[IAccountManager::PROPERTY_PHONE]['value'] !== '') { - $updated = $this->accountManager->updateUser($user, $account); + if ($property->getValue() !== '') { + $this->accountManager->updateAccount($account); + $updatedAccount = $this->accountManager->getAccount($user); + $updatedProperty = $updatedAccount->getProperty(IAccountManager::PROPERTY_PHONE); - if ($account[IAccountManager::PROPERTY_PHONE]['value'] !== $updated[IAccountManager::PROPERTY_PHONE]['value']) { - if ($updated[IAccountManager::PROPERTY_PHONE]['value'] === '') { + if ($property->getValue() !== $updatedProperty->getValue()) { + if ($updatedProperty->getValue() === '') { $numRemoved++; } else { $numUpdated++; |