Skip to content

Commit

Permalink
feat(carddav): Map user's additional emails into the SAB card
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
  • Loading branch information
ChristophWurst committed May 4, 2023
1 parent 527de8a commit 8c727f2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion apps/dav/lib/CardDAV/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@

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 {

Expand All @@ -44,7 +46,13 @@ public function __construct(IAccountManager $accountManager) {
}

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();
Expand Down Expand Up @@ -75,6 +83,7 @@ public function createCardFromUser(IUser $user): ?VCard {
$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;
Expand Down

0 comments on commit 8c727f2

Please sign in to comment.