diff options
author | Vincent Petry <vincent@nextcloud.com> | 2022-06-10 17:56:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-10 17:56:37 +0300 |
commit | 804ee11803a1fd7a5ac88793e77bd6b56a31bea0 (patch) | |
tree | 71733353d8037730c115189b29bf2a18fbf905e0 /apps/dav/lib/Connector | |
parent | 5f8e1b7fb98c4d32794b76792dcb7d8fa6a6fe6a (diff) | |
parent | 190a71ecf9a39ea31c8296798a2011352b7394b2 (diff) |
Merge pull request #31029 from nextcloud/expose-extra-emails-in-dav
Expose additional emails in {DAV:}alternate-URI-set
Diffstat (limited to 'apps/dav/lib/Connector')
-rw-r--r-- | apps/dav/lib/Connector/Sabre/Principal.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/apps/dav/lib/Connector/Sabre/Principal.php b/apps/dav/lib/Connector/Sabre/Principal.php index 94e3978e67d..75bee4e7b42 100644 --- a/apps/dav/lib/Connector/Sabre/Principal.php +++ b/apps/dav/lib/Connector/Sabre/Principal.php @@ -41,6 +41,9 @@ use OC\KnownUser\KnownUserService; use OCA\Circles\Exceptions\CircleNotFoundException; use OCA\DAV\CalDAV\Proxy\ProxyMapper; use OCA\DAV\Traits\PrincipalProxyTrait; +use OCP\Accounts\IAccountManager; +use OCP\Accounts\IAccountProperty; +use OCP\Accounts\PropertyDoesNotExistException; use OCP\App\IAppManager; use OCP\AppFramework\QueryException; use OCP\Constants; @@ -64,6 +67,9 @@ class Principal implements BackendInterface { /** @var IGroupManager */ private $groupManager; + /** @var IAccountManager */ + private $accountManager; + /** @var IShareManager */ private $shareManager; @@ -95,6 +101,7 @@ class Principal implements BackendInterface { public function __construct(IUserManager $userManager, IGroupManager $groupManager, + IAccountManager $accountManager, IShareManager $shareManager, IUserSession $userSession, IAppManager $appManager, @@ -105,6 +112,7 @@ class Principal implements BackendInterface { string $principalPrefix = 'principals/users/') { $this->userManager = $userManager; $this->groupManager = $groupManager; + $this->accountManager = $accountManager; $this->shareManager = $shareManager; $this->userSession = $userSession; $this->appManager = $appManager; @@ -506,6 +514,7 @@ class Principal implements BackendInterface { /** * @param IUser $user * @return array + * @throws PropertyDoesNotExistException */ protected function userToPrincipal($user) { $userId = $user->getUID(); @@ -517,11 +526,18 @@ class Principal implements BackendInterface { '{http://nextcloud.com/ns}language' => $this->languageFactory->getUserLanguage($user), ]; + $account = $this->accountManager->getAccount($user); + $alternativeEmails = array_map(fn (IAccountProperty $property) => 'mailto:' . $property->getValue(), $account->getPropertyCollection(IAccountManager::COLLECTION_EMAIL)->getProperties()); + $email = $user->getSystemEMailAddress(); if (!empty($email)) { $principal['{http://sabredav.org/ns}email-address'] = $email; } + if (!empty($alternativeEmails)) { + $principal['{DAV:}alternate-URI-set'] = $alternativeEmails; + } + return $principal; } |