Skip to content

Commit 6a99d3a

Browse files
committed
Use account method to set all properties
Signed-off-by: Christopher Ng <chrng8@gmail.com>
1 parent 74a5d08 commit 6a99d3a

1 file changed

Lines changed: 2 additions & 18 deletions

File tree

apps/settings/lib/UserMigration/AccountMigrator.php

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
namespace OCA\Settings\UserMigration;
2828

2929
use InvalidArgumentException;
30-
use OC\Accounts\AccountProperty;
31-
use OC\Accounts\AccountPropertyCollection;
3230
use OC\Accounts\TAccountsHelper;
3331
use OC\NotSquareException;
3432
use OCP\Accounts\IAccountManager;
@@ -97,24 +95,10 @@ public function import(IUser $user, IImportSource $importSource, OutputInterface
9795

9896
$account = $this->accountManager->getAccount($user);
9997

100-
/** @var array<string, array> $data */
98+
/** @var array<string, array<string, string>>|array<string, array<int, array<string, string>>> $data */
10199
$data = json_decode($importSource->getFileContents(AccountMigrator::EXPORT_ACCOUNT_FILE), true, 512, JSON_THROW_ON_ERROR);
102100

103-
foreach ($data as $propertyName => $propertyData) {
104-
if ($this->isCollection($propertyName)) {
105-
$collection = new AccountPropertyCollection($propertyName);
106-
/** @var array<int, array{name: string, value: string, scope: string, verified: string, verificationData: string}> $collectionData */
107-
$collectionData = $propertyData[$propertyName];
108-
foreach ($collectionData as ['value' => $value, 'scope' => $scope, 'verified' => $verified, 'verificationData' => $verificationData]) {
109-
$collection->addProperty(new AccountProperty($collection->getName(), $value, $scope, $verified, $verificationData));
110-
}
111-
$account->setPropertyCollection($collection);
112-
} else {
113-
/** @var array{name: string, value: string, scope: string, verified: string, verificationData: string} $propertyData */
114-
['value' => $value, 'scope' => $scope, 'verified' => $verified, 'verificationData' => $verificationData] = $propertyData;
115-
$account->setProperty($propertyName, $value, $scope, $verified, $verificationData);
116-
}
117-
}
101+
$account->setAllPropertiesFromJson($data);
118102

119103
try {
120104
$this->accountManager->updateAccount($account);

0 commit comments

Comments
 (0)