]> source.dussan.org Git - nextcloud-server.git/commitdiff
feat(carddav): Map user's additional emails into the SAB card 38073/head
authorChristoph Wurst <christoph@winzerhof-wurst.at>
Thu, 4 May 2023 13:03:01 +0000 (15:03 +0200)
committerChristoph Wurst <christoph@winzerhof-wurst.at>
Thu, 4 May 2023 13:03:01 +0000 (15:03 +0200)
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
apps/dav/lib/CardDAV/Converter.php

index 4c7d6f9075f768ea3fa1c84414d9a7776745cc00..409fce6210562bf7930ab2998afeb61a6a55d69a 100644 (file)
@@ -29,10 +29,12 @@ namespace OCA\DAV\CardDAV;
 
 use Exception;
 use OCP\Accounts\IAccountManager;
+use OCP\Accounts\PropertyDoesNotExistException;
 use OCP\IImage;
 use OCP\IUser;
 use Sabre\VObject\Component\VCard;
 use Sabre\VObject\Property\Text;
+use function array_merge;
 
 class Converter {
 
@@ -44,7 +46,13 @@ class Converter {
        }
 
        public function createCardFromUser(IUser $user): ?VCard {
-               $userProperties = $this->accountManager->getAccount($user)->getProperties();
+               $account = $this->accountManager->getAccount($user);
+               $userProperties = $account->getProperties();
+               try {
+                       $additionalEmailsCollection = $account->getPropertyCollection(IAccountManager::COLLECTION_EMAIL);
+                       $userProperties = array_merge($userProperties, $additionalEmailsCollection->getProperties());
+               } catch (PropertyDoesNotExistException $e) {
+               }
 
                $uid = $user->getUID();
                $cloudId = $user->getCloudId();
@@ -75,6 +83,7 @@ class Converter {
                                                        $vCard->add('PHOTO', $image->data(), ['ENCODING' => 'b', 'TYPE' => $image->mimeType()]);
                                                }
                                                break;
+                                       case IAccountManager::COLLECTION_EMAIL:
                                        case IAccountManager::PROPERTY_EMAIL:
                                                $vCard->add(new Text($vCard, 'EMAIL', $property->getValue(), ['TYPE' => 'OTHER']));
                                                break;