diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-08-01 13:56:35 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-10-04 08:19:07 +0200 |
commit | c8d50538b8488b56f252fbbb23893adf1b807471 (patch) | |
tree | d67b3b97b27fb1f89b1dac8db68d35ff09c50baf /apps/files_sharing/lib | |
parent | 6d819e2820c3a8c0ecd900ce9f3328b921ceb2a7 (diff) | |
download | nextcloud-server-c8d50538b8488b56f252fbbb23893adf1b807471.tar.gz nextcloud-server-c8d50538b8488b56f252fbbb23893adf1b807471.zip |
Use same settings for mail share as link shares
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareAPIController.php | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 86573bcfd79..5072db60fc4 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -453,8 +453,10 @@ class ShareAPIController extends OCSController { } $share->setSharedWith($shareWith); $share->setPermissions($permissions); - } else if ($shareType === Share::SHARE_TYPE_LINK) { - //Can we even share links? + } else if ($shareType === Share::SHARE_TYPE_LINK + || $shareType === Share::SHARE_TYPE_EMAIL) { + + // Can we even share links? if (!$this->shareManager->shareApiAllowLinks()) { throw new OCSNotFoundException($this->l->t('Public link sharing is disabled by the administrator')); } @@ -485,11 +487,17 @@ class ShareAPIController extends OCSController { $share->setPassword($password); } - - if (!empty($label)) { - $share->setLabel($label); + // Only share by mail have a recipient + if ($shareType === Share::SHARE_TYPE_EMAIL) { + $share->setSharedWith($shareWith); + } else { + // Only link share have a label + if (!empty($label)) { + $share->setLabel($label); + } } + if ($sendPasswordByTalk === 'true') { if (!$this->appManager->isEnabledForUser('spreed')) { throw new OCSForbiddenException($this->l->t('Sharing %s sending the password by Nextcloud Talk failed because Nextcloud Talk is not enabled', [$path->getPath()])); @@ -522,21 +530,6 @@ class ShareAPIController extends OCSController { $share->setSharedWith($shareWith); $share->setPermissions($permissions); - } else if ($shareType === Share::SHARE_TYPE_EMAIL) { - if ($share->getNodeType() === 'file') { - $share->setPermissions(Constants::PERMISSION_READ); - } else { - $share->setPermissions($permissions); - } - $share->setSharedWith($shareWith); - - if ($sendPasswordByTalk === 'true') { - if (!$this->appManager->isEnabledForUser('spreed')) { - throw new OCSForbiddenException($this->l->t('Sharing %s sending the password by Nextcloud Talk failed because Nextcloud Talk is not enabled', [$path->getPath()])); - } - - $share->setSendPasswordByTalk(true); - } } else if ($shareType === Share::SHARE_TYPE_CIRCLE) { if (!\OC::$server->getAppManager()->isEnabledForUser('circles') || !class_exists('\OCA\Circles\ShareByCircleProvider')) { throw new OCSNotFoundException($this->l->t('You cannot share to a Circle if the app is not enabled')); |