summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2022-02-05 19:55:23 +0100
committerThomas Citharel <tcit@tcit.fr>2022-05-17 15:11:36 +0200
commit190a71ecf9a39ea31c8296798a2011352b7394b2 (patch)
tree2a0d41736ebc58934e29e4faf8faf9432d360f58 /apps/dav/lib
parent07c9bf1adff8a2d10ff774da32c2ddd54fd01923 (diff)
downloadnextcloud-server-190a71ecf9a39ea31c8296798a2011352b7394b2.tar.gz
nextcloud-server-190a71ecf9a39ea31c8296798a2011352b7394b2.zip
Expose additional emails in {DAV:}alternate-URI-set
This allows iMip invitations to be send with an alternative email as "Reply-To" field. Closes #27201 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Diffstat (limited to 'apps/dav/lib')
-rw-r--r--apps/dav/lib/Command/CreateCalendar.php2
-rw-r--r--apps/dav/lib/Connector/Sabre/Principal.php16
-rw-r--r--apps/dav/lib/RootCollection.php2
3 files changed, 20 insertions, 0 deletions
diff --git a/apps/dav/lib/Command/CreateCalendar.php b/apps/dav/lib/Command/CreateCalendar.php
index 2bea82a345e..8a945f32eba 100644
--- a/apps/dav/lib/Command/CreateCalendar.php
+++ b/apps/dav/lib/Command/CreateCalendar.php
@@ -29,6 +29,7 @@ use OC\KnownUser\KnownUserService;
use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\CalDAV\Proxy\ProxyMapper;
use OCA\DAV\Connector\Sabre\Principal;
+use OCP\Accounts\IAccountManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IDBConnection;
@@ -83,6 +84,7 @@ class CreateCalendar extends Command {
$principalBackend = new Principal(
$this->userManager,
$this->groupManager,
+ \OC::$server->get(IAccountManager::class),
\OC::$server->getShareManager(),
\OC::$server->getUserSession(),
\OC::$server->getAppManager(),
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;
}
diff --git a/apps/dav/lib/RootCollection.php b/apps/dav/lib/RootCollection.php
index 8a11a676609..359037587a5 100644
--- a/apps/dav/lib/RootCollection.php
+++ b/apps/dav/lib/RootCollection.php
@@ -43,6 +43,7 @@ use OCA\DAV\DAV\GroupPrincipalBackend;
use OCA\DAV\DAV\SystemPrincipalBackend;
use OCA\DAV\Provisioning\Apple\AppleProvisioningNode;
use OCA\DAV\Upload\CleanupService;
+use OCP\Accounts\IAccountManager;
use OCP\App\IAppManager;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\EventDispatcher\IEventDispatcher;
@@ -68,6 +69,7 @@ class RootCollection extends SimpleCollection {
$userPrincipalBackend = new Principal(
$userManager,
$groupManager,
+ \OC::$server->get(IAccountManager::class),
$shareManager,
\OC::$server->getUserSession(),
\OC::$server->getAppManager(),