If a user deletes a group share we create a special share entry. To the API this is just a normal group share for that user with permissions 0. But we should not return this.tags/v9.0beta1
@@ -335,7 +335,9 @@ class Share20OCS { | |||
$formatted = []; | |||
foreach ($shares as $share) { | |||
$formatted[] = $this->formatShare($share); | |||
if ($this->canAccessShare($share)) { | |||
$formatted[] = $this->formatShare($share); | |||
} | |||
} | |||
return new \OC_OCS_Result($formatted); | |||
@@ -430,6 +432,11 @@ class Share20OCS { | |||
* @return bool | |||
*/ | |||
protected function canAccessShare(IShare $share) { | |||
// A file with permissions 0 can't be accessed by us. So Don't show it | |||
if ($share->getPermissions() === 0) { | |||
return false; | |||
} | |||
// Owner of the file and the sharer of the file can always get share | |||
if ($share->getShareOwner() === $this->currentUser || | |||
$share->getSharedBy() === $this->currentUser |
@@ -697,7 +697,7 @@ class DefaultShareProvider implements IShareProvider { | |||
$stmt->closeCursor(); | |||
if ($data !== false) { | |||
$share->setPermissions($data['permissions']); | |||
$share->setPermissions((int)$data['permissions']); | |||
$share->setTarget($data['file_target']); | |||
} | |||
@@ -943,13 +943,13 @@ class DefaultShareProviderTest extends \Test\TestCase { | |||
$this->assertCount(1, $share); | |||
$share = $share[0]; | |||
$this->assertEquals($id, $share->getId()); | |||
$this->assertEquals($group, $share->getSharedWith()); | |||
$this->assertEquals($owner, $share->getShareOwner()); | |||
$this->assertEquals($initiator, $share->getSharedBy()); | |||
$this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType()); | |||
$this->assertEquals(0, $share->getPermissions()); | |||
$this->assertEquals('userTarget', $share->getTarget()); | |||
$this->assertSame($id, $share->getId()); | |||
$this->assertSame($group, $share->getSharedWith()); | |||
$this->assertSame($owner, $share->getShareOwner()); | |||
$this->assertSame($initiator, $share->getSharedBy()); | |||
$this->assertSame(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType()); | |||
$this->assertSame(0, $share->getPermissions()); | |||
$this->assertSame('userTarget', $share->getTarget()); | |||
} | |||
public function testGetSharesBy() { |