diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index b54f8a69fd..29aa594df5 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -997,6 +997,6 @@ class FederatedShareProvider implements IShareProvider { $remote = $cursor->fetch() !== false; $cursor->closeCursor(); - return ['users' => [], 'remote' => $remote, 'public' => false]; + return ['remote' => $remote]; } } diff --git a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php index d9bc9a7e2a..7d571b2082 100644 --- a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php +++ b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php @@ -788,4 +788,32 @@ class FederatedShareProviderTest extends \Test\TestCase { $u1->delete(); $u2->delete(); } + + public function testGetAccessList() { + $userManager = \OC::$server->getUserManager(); + $rootFolder = \OC::$server->getRootFolder(); + + $u1 = $userManager->createUser('testFed', md5(time())); + + $folder1 = $rootFolder->getUserFolder($u1->getUID())->newFolder('foo'); + $file1 = $folder1->newFile('bar1'); + + $this->tokenHandler->method('generateToken')->willReturn('token'); + $this->notifications + ->method('sendRemoteShare') + ->willReturn(true); + + $share1 = $this->shareManager->newShare(); + $share1->setSharedWith('user@server.com') + ->setSharedBy($u1->getUID()) + ->setShareOwner($u1->getUID()) + ->setPermissions(\OCP\Constants::PERMISSION_READ) + ->setNode($file1); + $this->provider->create($share1); + + $result = $this->provider->getAccessList([$file1], true); + + $this->assertSame(['remote' => true], $result); + $u1->delete(); + } } diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index c367130487..14ed12749b 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -835,7 +835,27 @@ class ShareByMailProvider implements IShareProvider { } public function getAccessList($nodes, $currentAccess) { - return ['users' => [], 'remote' => false, 'public' => false]; + $ids = []; + foreach ($nodes as $node) { + $ids[] = $node->getId(); + } + + $qb = $this->dbConnection->getQueryBuilder(); + $qb->select('share_with') + ->from('share') + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_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->execute(); + + $mail = $cursor->fetch() !== false; + $cursor->closeCursor(); + + return ['mail' => $mail]; } } diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index 93e8cfc9d7..b8f46a1f4d 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -1138,6 +1138,6 @@ class DefaultShareProvider implements IShareProvider { return $count > 0; }); - return ['users' => array_keys($users), 'public' => $link, 'remote' => false]; + return ['users' => array_keys($users), 'public' => $link]; } } diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 096d05fbec..f1ce66f008 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -1236,9 +1236,17 @@ class Manager implements IManager { foreach ($providers as $provider) { $tmp = $provider->getAccessList($nodes, $currentAccess); - $al['users'] = array_merge($al['users'], $tmp['users']); - $al['public'] = $al['public'] || $tmp['public']; - $al['remote'] = $al['remote'] || $tmp['remote']; + foreach ($tmp as $k => $v) { + if (isset($al[$k])) { + if (is_array($al[$k])) { + $al[$k] = array_merge($al[$k], $v); + } else { + $al[$k] = $al[$k] || $v; + } + } else { + $al[$k] = $v; + } + } } $al['users'] = array_unique($al['users']); diff --git a/tests/lib/Share20/DefaultShareProviderTest.php b/tests/lib/Share20/DefaultShareProviderTest.php index ccc9f0f511..a7f5555efa 100644 --- a/tests/lib/Share20/DefaultShareProviderTest.php +++ b/tests/lib/Share20/DefaultShareProviderTest.php @@ -2508,7 +2508,6 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertContains('testShare4', $result['users']); $this->assertContains('testShare5', $result['users']); $this->assertTrue($result['public']); - $this->assertFalse($result['remote']); $provider->delete($share1); $provider->delete($share2); @@ -2595,7 +2594,6 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertContains('testShare3', $result['users']); $this->assertContains('testShare5', $result['users']); $this->assertTrue($result['public']); - $this->assertFalse($result['remote']); $provider->delete($share1); $provider->delete($share2); diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php index ab42cb4813..c1a0eaf5bb 100644 --- a/tests/lib/Share20/ManagerTest.php +++ b/tests/lib/Share20/ManagerTest.php @@ -2804,7 +2804,6 @@ class ManagerTest extends \Test\TestCase { 'user2', 'user3', ], - 'remote' => false, 'public' => true, ]); @@ -2820,7 +2819,6 @@ class ManagerTest extends \Test\TestCase { 'user5', ], 'remote' => true, - 'public' => false, ]); $this->rootFolder->method('getUserFolder')