diff options
author | Andy Scherzinger <info@andy-scherzinger.de> | 2024-03-25 12:40:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-25 12:40:10 +0100 |
commit | 46906b7d69642f7e5b1dc031e00921b39b27dce8 (patch) | |
tree | 0df20e15b045891d4b4113f79a51bfaf80a2c2bf | |
parent | c352f0198b502b0efa004252b204f7f68b3421ea (diff) | |
parent | f45eb75e3de1d82695f38f49f28e69278b7f9dbb (diff) | |
download | nextcloud-server-46906b7d69642f7e5b1dc031e00921b39b27dce8.tar.gz nextcloud-server-46906b7d69642f7e5b1dc031e00921b39b27dce8.zip |
Merge pull request #32631 from nextcloud/feature/32629/getAccessList-share-by-email-recipients
Get access list share by email recipients
-rw-r--r-- | apps/sharebymail/lib/ShareByMailProvider.php | 21 | ||||
-rw-r--r-- | lib/private/Share20/Manager.php | 14 | ||||
-rw-r--r-- | lib/public/Share/IManager.php | 11 |
3 files changed, 32 insertions, 14 deletions
diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index 5a840b895ff..f1bb3fe94ca 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -1098,21 +1098,32 @@ class ShareByMailProvider implements IShareProvider { } $qb = $this->dbConnection->getQueryBuilder(); - $qb->select('share_with') + $qb->select('share_with', 'file_source', 'token') ->from('share') ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))) ->andWhere($qb->expr()->in('file_source', $qb->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY))) ->andWhere($qb->expr()->orX( $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) - )) - ->setMaxResults(1); + )); $cursor = $qb->executeQuery(); - $mail = $cursor->fetch() !== false; + $public = false; + $mail = []; + while ($row = $cursor->fetch()) { + $public = true; + if ($currentAccess === false) { + $mail[] = $row['share_with']; + } else { + $mail[$row['share_with']] = [ + 'node_id' => $row['file_source'], + 'token' => $row['token'] + ]; + } + } $cursor->closeCursor(); - return ['public' => $mail]; + return ['public' => $public, 'mail' => $mail]; } public function getAllShares(): iterable { diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index af124ca8bc9..2bef6ba3ce7 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -1672,9 +1672,10 @@ class Manager implements IManager { * |-folder2 (32) * |-fileA (42) * - * fileA is shared with user1 and user1@server1 + * fileA is shared with user1 and user1@server1 and email1@maildomain1 * folder2 is shared with group2 (user4 is a member of group2) * folder1 is shared with user2 (renamed to "folder (1)") and user2@server2 + * and email2@maildomain2 * * Then the access list to '/folder1/folder2/fileA' with $currentAccess is: * [ @@ -1688,7 +1689,10 @@ class Manager implements IManager { * 'user2@server2' => ['node_id' => 23, 'token' => 'FooBaR'], * ], * public => bool - * mail => bool + * mail => [ + * 'email1@maildomain1' => ['node_id' => 42, 'token' => 'aBcDeFg'], + * 'email2@maildomain2' => ['node_id' => 23, 'token' => 'hIjKlMn'], + * ] * ] * * The access list to '/folder1/folder2/fileA' **without** $currentAccess is: @@ -1696,7 +1700,7 @@ class Manager implements IManager { * users => ['user1', 'user2', 'user4'], * remote => bool, * public => bool - * mail => bool + * mail => ['email1@maildomain1', 'email2@maildomain2'] * ] * * This is required for encryption/activity @@ -1716,9 +1720,9 @@ class Manager implements IManager { $owner = $owner->getUID(); if ($currentAccess) { - $al = ['users' => [], 'remote' => [], 'public' => false]; + $al = ['users' => [], 'remote' => [], 'public' => false, 'mail' => []]; } else { - $al = ['users' => [], 'remote' => false, 'public' => false]; + $al = ['users' => [], 'remote' => false, 'public' => false, 'mail' => []]; } if (!$this->userManager->userExists($owner)) { return $al; diff --git a/lib/public/Share/IManager.php b/lib/public/Share/IManager.php index 07517dd7eb5..1c75b306fe2 100644 --- a/lib/public/Share/IManager.php +++ b/lib/public/Share/IManager.php @@ -256,9 +256,10 @@ interface IManager { * |-folder2 (32) * |-fileA (42) * - * fileA is shared with user1 and user1@server1 + * fileA is shared with user1 and user1@server1 and email1@maildomain1 * folder2 is shared with group2 (user4 is a member of group2) * folder1 is shared with user2 (renamed to "folder (1)") and user2@server2 + * and email2@maildomain2 * * Then the access list to '/folder1/folder2/fileA' with $currentAccess is: * [ @@ -272,15 +273,17 @@ interface IManager { * 'user2@server2' => ['node_id' => 23, 'token' => 'FooBaR'], * ], * public => bool - * mail => bool - * ] + * mail => [ + * 'email1@maildomain1' => ['node_id' => 42, 'token' => 'aBcDeFg'], + * 'email2@maildomain2' => ['node_id' => 23, 'token' => 'hIjKlMn'], + * ] * * The access list to '/folder1/folder2/fileA' **without** $currentAccess is: * [ * users => ['user1', 'user2', 'user4'], * remote => bool, * public => bool - * mail => bool + * mail => ['email1@maildomain1', 'email2@maildomain2'] * ] * * This is required for encryption/activity |