Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix remote group share decline+accept code path
When declining a remote group share through the dialog that appears when
notifications are off, the mount point is now correctly saved when
re-accepting.

Signed-off-by: Vincent Petry <[email protected]>
  • Loading branch information
PVince81 committed Aug 10, 2021
commit 2e76d98e1364f386f901e0698029d76fef67565f
8 changes: 7 additions & 1 deletion apps/files_sharing/lib/External/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,13 @@ public function acceptShare($id) {

if ($subshare !== null) {
try {
$this->updateAccepted((int)$subshare['id'], true);
$acceptShare = $this->connection->prepare('
UPDATE `*PREFIX*share_external`
SET `accepted` = ?,
`mountpoint` = ?,
`mountpoint_hash` = ?
WHERE `id` = ? AND `user` = ?');
$acceptShare->execute([1, $mountPoint, $hash, $subshare['id'], $this->uid]);
$result = true;
} catch (Exception $e) {
$this->logger->logException($e);
Expand Down
36 changes: 36 additions & 0 deletions apps/files_sharing/tests/External/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,42 @@ public function testDeclineGroupShareAgainThroughMountPoint() {
$this->assertFalse($this->manager->removeShare($this->uid . '/files/' . $shareData['name']));
}

public function testDeclineThenAcceptGroupShareAgainThroughGroupShare() {
[$shareData, $groupShare] = $this->createTestGroupShare();
// decline, this creates a declined sub-share
$this->assertTrue($this->manager->declineShare($groupShare['id']));
$this->verifyDeclinedGroupShare($shareData);

// this will return sub-entries
$openShares = $this->manager->getOpenShares();

// accept through sub-share
$this->assertTrue($this->manager->acceptShare($groupShare['id']));
$this->verifyAcceptedGroupShare($shareData, '/SharedFolder');

// accept a second time
$this->assertTrue($this->manager->acceptShare($groupShare['id']));
$this->verifyAcceptedGroupShare($shareData, '/SharedFolder');
}

public function testDeclineThenAcceptGroupShareAgainThroughSubShare() {
[$shareData, $groupShare] = $this->createTestGroupShare();
// decline, this creates a declined sub-share
$this->assertTrue($this->manager->declineShare($groupShare['id']));
$this->verifyDeclinedGroupShare($shareData);

// this will return sub-entries
$openShares = $this->manager->getOpenShares();

// accept through sub-share
$this->assertTrue($this->manager->acceptShare($openShares[0]['id']));
$this->verifyAcceptedGroupShare($shareData);

// accept a second time
$this->assertTrue($this->manager->acceptShare($openShares[0]['id']));
$this->verifyAcceptedGroupShare($shareData);
}

/**
* @param array $expected
* @param array $actual
Expand Down