aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/CardDAV/Converter.php
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2023-05-04 15:03:01 +0200
committerChristoph Wurst <christoph@winzerhof-wurst.at>2023-05-04 15:03:01 +0200
commit8c727f2285b49c6e7e46bd65b41d71d18c195efa (patch)
tree910d69811d1c77394ffa41024796a6a03ae142fe /apps/dav/lib/CardDAV/Converter.php
parent527de8ac9d989baf30144e8f9bc0381226d4aee9 (diff)
downloadnextcloud-server-8c727f2285b49c6e7e46bd65b41d71d18c195efa.tar.gz
nextcloud-server-8c727f2285b49c6e7e46bd65b41d71d18c195efa.zip
feat(carddav): Map user's additional emails into the SAB card
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/dav/lib/CardDAV/Converter.php')
-rw-r--r--apps/dav/lib/CardDAV/Converter.php11
1 files changed, 10 insertions, 1 deletions
diff --git a/apps/dav/lib/CardDAV/Converter.php b/apps/dav/lib/CardDAV/Converter.php
index 4c7d6f9075f..409fce62105 100644
--- a/apps/dav/lib/CardDAV/Converter.php
+++ b/apps/dav/lib/CardDAV/Converter.php
@@ -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;