diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2018-06-29 13:50:25 +0200 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2018-08-08 14:25:43 +0200 |
commit | 8084ba516f637e1e08e32712dde433c1d3474ef6 (patch) | |
tree | fda717ba2d3ac87693b0d10b25c84be6cbe9b443 | |
parent | de403f2f3da09015a07400d90703642a5eabcc65 (diff) | |
download | nextcloud-server-8084ba516f637e1e08e32712dde433c1d3474ef6.tar.gz nextcloud-server-8084ba516f637e1e08e32712dde433c1d3474ef6.zip |
Add room shares to the MountProvider for shares
The MountProvider for shares creates mount points for the files shared
with the user, which makes possible to use the received shared files and
folders as regular files and folders.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
-rw-r--r-- | apps/files_sharing/lib/MountProvider.php | 1 | ||||
-rw-r--r-- | apps/files_sharing/tests/MountProviderTest.php | 24 |
2 files changed, 24 insertions, 1 deletions
diff --git a/apps/files_sharing/lib/MountProvider.php b/apps/files_sharing/lib/MountProvider.php index fd4c537210f..cb02a2b5f23 100644 --- a/apps/files_sharing/lib/MountProvider.php +++ b/apps/files_sharing/lib/MountProvider.php @@ -74,6 +74,7 @@ class MountProvider implements IMountProvider { $shares = $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_USER, null, -1); $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_GROUP, null, -1)); $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_CIRCLE, null, -1)); + $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_ROOM, null, -1)); // filter out excluded shares and group shares that includes self $shares = array_filter($shares, function (\OCP\Share\IShare $share) use ($user) { diff --git a/apps/files_sharing/tests/MountProviderTest.php b/apps/files_sharing/tests/MountProviderTest.php index b521e109cf9..7b533bf8106 100644 --- a/apps/files_sharing/tests/MountProviderTest.php +++ b/apps/files_sharing/tests/MountProviderTest.php @@ -114,6 +114,12 @@ class MountProviderTest extends \Test\TestCase { $this->makeMockShare(4, 101, 'user2', '/share4', 31), $this->makeMockShare(5, 100, 'user1', '/share4', 31), ]; + $roomShares = [ + $this->makeMockShare(6, 102, 'user2', '/share6', 0), + $this->makeMockShare(7, 102, 'user1', '/share6', 31), + $this->makeMockShare(8, 102, 'user2', '/share6', 31), + $this->makeMockShare(9, 102, 'user2', '/share6', 31), + ]; // tests regarding circles are made in the app itself. $circleShares = []; $this->user->expects($this->any()) @@ -131,15 +137,20 @@ class MountProviderTest extends \Test\TestCase { ->method('getSharedWith') ->with('user1', \OCP\Share::SHARE_TYPE_CIRCLE, null, -1) ->will($this->returnValue($circleShares)); + $this->shareManager->expects($this->at(3)) + ->method('getSharedWith') + ->with('user1', \OCP\Share::SHARE_TYPE_ROOM, null, -1) + ->will($this->returnValue($roomShares)); $this->shareManager->expects($this->any()) ->method('newShare') ->will($this->returnCallback(function() use ($rootFolder, $userManager) { return new \OC\Share20\Share($rootFolder, $userManager); })); $mounts = $this->provider->getMountsForUser($this->user, $this->loader); - $this->assertCount(2, $mounts); + $this->assertCount(3, $mounts); $this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mounts[0]); $this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mounts[1]); + $this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mounts[2]); $mountedShare1 = $mounts[0]->getShare(); $this->assertEquals('2', $mountedShare1->getId()); $this->assertEquals('user2', $mountedShare1->getShareOwner()); @@ -152,6 +163,12 @@ class MountProviderTest extends \Test\TestCase { $this->assertEquals(101, $mountedShare2->getNodeId()); $this->assertEquals('/share4', $mountedShare2->getTarget()); $this->assertEquals(31, $mountedShare2->getPermissions()); + $mountedShare3 = $mounts[2]->getShare(); + $this->assertEquals('8', $mountedShare3->getId()); + $this->assertEquals('user2', $mountedShare3->getShareOwner()); + $this->assertEquals(102, $mountedShare3->getNodeId()); + $this->assertEquals('/share6', $mountedShare3->getTarget()); + $this->assertEquals(31, $mountedShare3->getPermissions()); } public function mergeSharesDataProvider() { @@ -316,6 +333,7 @@ class MountProviderTest extends \Test\TestCase { // tests regarding circles are made in the app itself. $circleShares = []; + $roomShares = []; $this->shareManager->expects($this->at(0)) ->method('getSharedWith') ->with('user1', \OCP\Share::SHARE_TYPE_USER) @@ -328,6 +346,10 @@ class MountProviderTest extends \Test\TestCase { ->method('getSharedWith') ->with('user1', \OCP\Share::SHARE_TYPE_CIRCLE, null, -1) ->will($this->returnValue($circleShares)); + $this->shareManager->expects($this->at(3)) + ->method('getSharedWith') + ->with('user1', \OCP\Share::SHARE_TYPE_ROOM, null, -1) + ->will($this->returnValue($roomShares)); $this->shareManager->expects($this->any()) ->method('newShare') ->will($this->returnCallback(function() use ($rootFolder, $userManager) { |