Merge pull request #22700 from owncloud/only_1_linkshare
For now only allow 1 link share per file/folder
This commit is contained in:
commit
1652541150
|
@ -303,6 +303,15 @@ class Share20OCS {
|
||||||
return new \OC_OCS_Result(null, 404, 'public link sharing is disabled by the administrator');
|
return new \OC_OCS_Result(null, 404, 'public link sharing is disabled by the administrator');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For now we only allow 1 link share.
|
||||||
|
* Return the existing link share if this is a duplicate
|
||||||
|
*/
|
||||||
|
$existingShares = $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_LINK, $path, false, 1, 0);
|
||||||
|
if (!empty($existingShares)) {
|
||||||
|
return new \OC_OCS_Result($this->formatShare($existingShares[0]));
|
||||||
|
}
|
||||||
|
|
||||||
$publicUpload = $this->request->getParam('publicUpload', null);
|
$publicUpload = $this->request->getParam('publicUpload', null);
|
||||||
if ($publicUpload === 'true') {
|
if ($publicUpload === 'true') {
|
||||||
// Check if public upload is allowed
|
// Check if public upload is allowed
|
||||||
|
|
|
@ -17,6 +17,9 @@ trait Sharing{
|
||||||
/** @var SimpleXMLElement */
|
/** @var SimpleXMLElement */
|
||||||
private $lastShareData = null;
|
private $lastShareData = null;
|
||||||
|
|
||||||
|
/** @var int */
|
||||||
|
private $savedShareId = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^as "([^"]*)" creating a share with$/
|
* @Given /^as "([^"]*)" creating a share with$/
|
||||||
* @param \Behat\Gherkin\Node\TableNode|null $formData
|
* @param \Behat\Gherkin\Node\TableNode|null $formData
|
||||||
|
@ -422,5 +425,22 @@ trait Sharing{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @When save last share id
|
||||||
|
*/
|
||||||
|
public function saveLastShareId()
|
||||||
|
{
|
||||||
|
$this->savedShareId = $this->lastShareData['data']['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Then share ids should match
|
||||||
|
*/
|
||||||
|
public function shareIdsShouldMatch()
|
||||||
|
{
|
||||||
|
if ($this->savedShareId !== $this->lastShareData['data']['id']) {
|
||||||
|
throw new \Excetion('Expected the same link share to be returned');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -547,3 +547,15 @@ Feature: sharing
|
||||||
When Updating last share with
|
When Updating last share with
|
||||||
| permissions | 31 |
|
| permissions | 31 |
|
||||||
Then the OCS status code should be "404"
|
Then the OCS status code should be "404"
|
||||||
|
|
||||||
|
Scenario: Only allow 1 link share per file/folder
|
||||||
|
Given user "user0" exists
|
||||||
|
And As an "user0"
|
||||||
|
And creating a share with
|
||||||
|
| path | welcome.txt |
|
||||||
|
| shareType | 3 |
|
||||||
|
When save last share id
|
||||||
|
And creating a share with
|
||||||
|
| path | welcome.txt |
|
||||||
|
| shareType | 3 |
|
||||||
|
Then share ids should match
|
||||||
|
|
Loading…
Reference in New Issue