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

feat(carddav): Map user's additional emails into the SAB card #38073

Merged
Merged
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
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();

Check notice

Code scanning / Psalm

DeprecatedMethod

The method OCP\Accounts\IAccount::getProperties has been marked as deprecated
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