Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable21] Allow apps to write/update account data #26398

Merged
merged 1 commit into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/private/Accounts/AccountManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,4 +510,18 @@ private function parseAccountData(IUser $user, $data): Account {
public function getAccount(IUser $user): IAccount {
return $this->parseAccountData($user, $this->getUser($user));
}

public function updateAccount(IAccount $account): void {
$data = [];

foreach ($account->getProperties() as $property) {
$data[$property->getName()] = [
'value' => $property->getValue(),
'scope' => $property->getScope(),
'verified' => $property->getVerified(),
];
}

$this->updateUser($account->getUser(), $data, true);
}
}
10 changes: 10 additions & 0 deletions lib/public/Accounts/IAccountManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ interface IAccountManager {
*/
public function getAccount(IUser $user): IAccount;

/**
* Update the account data with for the user
*
* @since 21.0.1
*
* @param IAccount $account
* @throws \InvalidArgumentException Message is the property that was invalid
*/
public function updateAccount(IAccount $account): void;

/**
* Search for users based on account data
*
Expand Down