Skip to content

Commit

Permalink
Enable option to set the file_target of a new share via api.
Browse files Browse the repository at this point in the history
Signed-off-by: Jacqueline Lüken <j.lueken@mhq-services.com>
  • Loading branch information
Jaco committed Nov 23, 2018
1 parent eadfa90 commit a9ae3d9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 6 additions & 1 deletion apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ public function deleteShare(string $id): DataResponse {
* @param string $sendPasswordByTalk
* @param string $expireDate
* @param string $label
* @param string $target
*
* @return DataResponse
* @throws NotFoundException
Expand All @@ -385,7 +386,8 @@ public function createShare(
string $password = '',
string $sendPasswordByTalk = null,
string $expireDate = '',
string $label = ''
string $label = '',
string $target = ''
): DataResponse {
$share = $this->shareManager->newShare();

Expand Down Expand Up @@ -562,6 +564,9 @@ public function createShare(

$share->setShareType($shareType);
$share->setSharedBy($this->currentUser);
if (!empty($target)) {
$share->setTarget($target);
}

try {
$share = $this->shareManager->createShare($share);
Expand Down
8 changes: 5 additions & 3 deletions lib/private/Share20/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -654,9 +654,11 @@ public function createShare(\OCP\Share\IShare $share) {
}

// Generate the target
$target = $this->config->getSystemValue('share_folder', '/') .'/'. $share->getNode()->getName();
$target = \OC\Files\Filesystem::normalizePath($target);
$share->setTarget($target);
if (empty($share->getTarget())) {
$target = $this->config->getSystemValue('share_folder', '/') . '/' . $share->getNode()->getName();
$target = \OC\Files\Filesystem::normalizePath($target);
$share->setTarget($target);
}

// Pre share event
$event = new GenericEvent($share);
Expand Down

0 comments on commit a9ae3d9

Please sign in to comment.