[Share 2.0] Properly handle user deleted group shares
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.
This commit is contained in:
parent
1df31c802b
commit
a4900d721f
|
@ -335,8 +335,10 @@ class Share20OCS {
|
||||||
|
|
||||||
$formatted = [];
|
$formatted = [];
|
||||||
foreach ($shares as $share) {
|
foreach ($shares as $share) {
|
||||||
|
if ($this->canAccessShare($share)) {
|
||||||
$formatted[] = $this->formatShare($share);
|
$formatted[] = $this->formatShare($share);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return new \OC_OCS_Result($formatted);
|
return new \OC_OCS_Result($formatted);
|
||||||
}
|
}
|
||||||
|
@ -430,6 +432,11 @@ class Share20OCS {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function canAccessShare(IShare $share) {
|
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
|
// Owner of the file and the sharer of the file can always get share
|
||||||
if ($share->getShareOwner() === $this->currentUser ||
|
if ($share->getShareOwner() === $this->currentUser ||
|
||||||
$share->getSharedBy() === $this->currentUser
|
$share->getSharedBy() === $this->currentUser
|
||||||
|
|
|
@ -697,7 +697,7 @@ class DefaultShareProvider implements IShareProvider {
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
if ($data !== false) {
|
if ($data !== false) {
|
||||||
$share->setPermissions($data['permissions']);
|
$share->setPermissions((int)$data['permissions']);
|
||||||
$share->setTarget($data['file_target']);
|
$share->setTarget($data['file_target']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -943,13 +943,13 @@ class DefaultShareProviderTest extends \Test\TestCase {
|
||||||
$this->assertCount(1, $share);
|
$this->assertCount(1, $share);
|
||||||
|
|
||||||
$share = $share[0];
|
$share = $share[0];
|
||||||
$this->assertEquals($id, $share->getId());
|
$this->assertSame($id, $share->getId());
|
||||||
$this->assertEquals($group, $share->getSharedWith());
|
$this->assertSame($group, $share->getSharedWith());
|
||||||
$this->assertEquals($owner, $share->getShareOwner());
|
$this->assertSame($owner, $share->getShareOwner());
|
||||||
$this->assertEquals($initiator, $share->getSharedBy());
|
$this->assertSame($initiator, $share->getSharedBy());
|
||||||
$this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
|
$this->assertSame(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
|
||||||
$this->assertEquals(0, $share->getPermissions());
|
$this->assertSame(0, $share->getPermissions());
|
||||||
$this->assertEquals('userTarget', $share->getTarget());
|
$this->assertSame('userTarget', $share->getTarget());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetSharesBy() {
|
public function testGetSharesBy() {
|
||||||
|
|
Loading…
Reference in New Issue