From 2ee34ff76c3fb847f93662007330457a5427babb Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 12 May 2021 13:58:37 +0200 Subject: [PATCH 1/2] Repair job to use public AccoutManager API Signed-off-by: Arthur Schiwon --- .../Repair/NC21/ValidatePhoneNumber.php | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/private/Repair/NC21/ValidatePhoneNumber.php b/lib/private/Repair/NC21/ValidatePhoneNumber.php index 995c38602f..ca79786f90 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++; From a49588bbe5c7c0a1852426149fecb39b3895c379 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 12 May 2021 14:06:06 +0200 Subject: [PATCH 2/2] PersonalInfo settings to use public AccoutManager API Signed-off-by: Arthur Schiwon --- apps/settings/lib/Settings/Personal/PersonalInfo.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/settings/lib/Settings/Personal/PersonalInfo.php b/apps/settings/lib/Settings/Personal/PersonalInfo.php index 7a0253d2be..dbe68b907f 100644 --- a/apps/settings/lib/Settings/Personal/PersonalInfo.php +++ b/apps/settings/lib/Settings/Personal/PersonalInfo.php @@ -35,7 +35,6 @@ declare(strict_types=1); namespace OCA\Settings\Settings\Personal; -use OC\Accounts\AccountManager; use OCA\FederatedFileSharing\FederatedShareProvider; use OCP\Accounts\IAccount; use OCP\Accounts\IAccountManager; @@ -57,7 +56,7 @@ class PersonalInfo implements ISettings { private $config; /** @var IUserManager */ private $userManager; - /** @var AccountManager */ + /** @var IAccountManager */ private $accountManager; /** @var IGroupManager */ private $groupManager; @@ -72,7 +71,7 @@ class PersonalInfo implements ISettings { IConfig $config, IUserManager $userManager, IGroupManager $groupManager, - AccountManager $accountManager, + IAccountManager $accountManager, IAppManager $appManager, IFactory $l10nFactory, IL10N $l @@ -272,10 +271,10 @@ class PersonalInfo implements ISettings { $messageParameters = []; foreach ($needVerifyMessage as $property) { switch ($account->getProperty($property)->getVerified()) { - case AccountManager::VERIFIED: + case IAccountManager::VERIFIED: $message = $this->l->t('Verifying'); break; - case AccountManager::VERIFICATION_IN_PROGRESS: + case IAccountManager::VERIFICATION_IN_PROGRESS: $message = $this->l->t('Verifying …'); break; default: