aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings/lib
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2022-03-18 04:10:22 +0000
committerChristopher Ng <chrng8@gmail.com>2022-03-18 04:51:26 +0000
commitad31cfe72d4cb02f000b98499cf284ae371f7d11 (patch)
treedf7722ae9fa4f5d63ea553cdb3b11fbec8fa4a08 /apps/settings/lib
parentbf79b97718d42c932222738e83690ce2cea06890 (diff)
downloadnextcloud-server-ad31cfe72d4cb02f000b98499cf284ae371f7d11.tar.gz
nextcloud-server-ad31cfe72d4cb02f000b98499cf284ae371f7d11.zip
Use account method to set all properties
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'apps/settings/lib')
-rw-r--r--apps/settings/lib/UserMigration/AccountMigrator.php20
1 files changed, 2 insertions, 18 deletions
diff --git a/apps/settings/lib/UserMigration/AccountMigrator.php b/apps/settings/lib/UserMigration/AccountMigrator.php
index 7129a8f8349..71b2b3afe20 100644
--- a/apps/settings/lib/UserMigration/AccountMigrator.php
+++ b/apps/settings/lib/UserMigration/AccountMigrator.php
@@ -27,8 +27,6 @@ declare(strict_types=1);
namespace OCA\Settings\UserMigration;
use InvalidArgumentException;
-use OC\Accounts\AccountProperty;
-use OC\Accounts\AccountPropertyCollection;
use OC\Accounts\TAccountsHelper;
use OC\NotSquareException;
use OCP\Accounts\IAccountManager;
@@ -97,24 +95,10 @@ class AccountMigrator implements IMigrator {
$account = $this->accountManager->getAccount($user);
- /** @var array<string, array> $data */
+ /** @var array<string, array<string, string>>|array<string, array<int, array<string, string>>> $data */
$data = json_decode($importSource->getFileContents(AccountMigrator::EXPORT_ACCOUNT_FILE), true, 512, JSON_THROW_ON_ERROR);
- foreach ($data as $propertyName => $propertyData) {
- if ($this->isCollection($propertyName)) {
- $collection = new AccountPropertyCollection($propertyName);
- /** @var array<int, array{name: string, value: string, scope: string, verified: string, verificationData: string}> $collectionData */
- $collectionData = $propertyData[$propertyName];
- foreach ($collectionData as ['value' => $value, 'scope' => $scope, 'verified' => $verified, 'verificationData' => $verificationData]) {
- $collection->addProperty(new AccountProperty($collection->getName(), $value, $scope, $verified, $verificationData));
- }
- $account->setPropertyCollection($collection);
- } else {
- /** @var array{name: string, value: string, scope: string, verified: string, verificationData: string} $propertyData */
- ['value' => $value, 'scope' => $scope, 'verified' => $verified, 'verificationData' => $verificationData] = $propertyData;
- $account->setProperty($propertyName, $value, $scope, $verified, $verificationData);
- }
- }
+ $account->setAllPropertiesFromJson($data);
try {
$this->accountManager->updateAccount($account);