diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2020-10-20 13:58:01 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2021-03-22 06:50:45 +0100 |
commit | a100186e5e7dcbe95faa453d28b5cf0d20948639 (patch) | |
tree | afea689f2b87338975c74aabba950d85f7dca338 /apps/sharebymail/lib | |
parent | 5e519fe17a2d4940993f4d866dfdd68269265a12 (diff) | |
download | nextcloud-server-a100186e5e7dcbe95faa453d28b5cf0d20948639.tar.gz nextcloud-server-a100186e5e7dcbe95faa453d28b5cf0d20948639.zip |
Sharing link & mail parity
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/sharebymail/lib')
-rw-r--r-- | apps/sharebymail/lib/Capabilities.php | 10 | ||||
-rw-r--r-- | apps/sharebymail/lib/Settings/Admin.php | 1 | ||||
-rw-r--r-- | apps/sharebymail/lib/Settings/SettingsManager.php | 12 | ||||
-rw-r--r-- | apps/sharebymail/lib/ShareByMailProvider.php | 36 |
4 files changed, 26 insertions, 33 deletions
diff --git a/apps/sharebymail/lib/Capabilities.php b/apps/sharebymail/lib/Capabilities.php index c78215c0c54..a982d3c0f6c 100644 --- a/apps/sharebymail/lib/Capabilities.php +++ b/apps/sharebymail/lib/Capabilities.php @@ -29,13 +29,14 @@ namespace OCA\ShareByMail; use OCA\ShareByMail\Settings\SettingsManager; use OCP\Capabilities\ICapability; +use OCP\Share\IManager; class Capabilities implements ICapability { - /** @var SettingsManager */ + /** @var IManager */ private $manager; - public function __construct(SettingsManager $manager) { + public function __construct(IManager $manager) { $this->manager = $manager; } @@ -45,16 +46,17 @@ class Capabilities implements ICapability { [ 'sharebymail' => [ - 'enabled' => true, + 'enabled' => $this->manager->shareApiAllowLinks(), 'upload_files_drop' => [ 'enabled' => true, ], 'password' => [ 'enabled' => true, - 'enforced' => $this->manager->enforcePasswordProtection(), + 'enforced' => $this->manager->shareApiLinkEnforcePassword(), ], 'expire_date' => [ 'enabled' => true, + 'enforced' => $this->manager->shareApiLinkDefaultExpireDateEnforced(), ], ] ] diff --git a/apps/sharebymail/lib/Settings/Admin.php b/apps/sharebymail/lib/Settings/Admin.php index bc766d59af6..95dce03e51e 100644 --- a/apps/sharebymail/lib/Settings/Admin.php +++ b/apps/sharebymail/lib/Settings/Admin.php @@ -41,7 +41,6 @@ class Admin implements ISettings { public function getForm() { $parameters = [ 'sendPasswordMail' => $this->settingsManager->sendPasswordByMail(), - 'enforcePasswordProtection' => $this->settingsManager->enforcePasswordProtection(), 'replyToInitiator' => $this->settingsManager->replyToInitiator() ]; diff --git a/apps/sharebymail/lib/Settings/SettingsManager.php b/apps/sharebymail/lib/Settings/SettingsManager.php index 4eb958bf955..8d9e7e92514 100644 --- a/apps/sharebymail/lib/Settings/SettingsManager.php +++ b/apps/sharebymail/lib/Settings/SettingsManager.php @@ -36,8 +36,6 @@ class SettingsManager { private $sendPasswordByMailDefault = 'yes'; - private $enforcePasswordProtectionDefault = 'no'; - private $replyToInitiatorDefault = 'yes'; public function __construct(IConfig $config) { @@ -55,16 +53,6 @@ class SettingsManager { } /** - * do we require a share by mail to be password protected - * - * @return bool - */ - public function enforcePasswordProtection(): bool { - $enforcePassword = $this->config->getAppValue('sharebymail', 'enforcePasswordProtection', $this->enforcePasswordProtectionDefault); - return $enforcePassword === 'yes'; - } - - /** * should add reply to with initiator mail * * @return bool diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index e1585955c62..f368ed0a573 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -61,6 +61,7 @@ use OCP\Security\IHasher; use OCP\Security\ISecureRandom; use OCP\Share\Exceptions\GenericShareException; use OCP\Share\Exceptions\ShareNotFound; +use OCP\Share\IManager as IShareManager; use OCP\Share\IShare; use OCP\Share\IShareProvider; @@ -110,6 +111,9 @@ class ShareByMailProvider implements IShareProvider { /** @var IEventDispatcher */ private $eventDispatcher; + /** @var IShareManager */ + private $shareManager; + /** * Return the identifier of this provider. * @@ -119,21 +123,20 @@ class ShareByMailProvider implements IShareProvider { return 'ocMailShare'; } - public function __construct( - IDBConnection $connection, - ISecureRandom $secureRandom, - IUserManager $userManager, - IRootFolder $rootFolder, - IL10N $l, - ILogger $logger, - IMailer $mailer, - IURLGenerator $urlGenerator, - IManager $activityManager, - SettingsManager $settingsManager, - Defaults $defaults, - IHasher $hasher, - IEventDispatcher $eventDispatcher - ) { + public function __construct(IDBConnection $connection, + ISecureRandom $secureRandom, + IUserManager $userManager, + IRootFolder $rootFolder, + IL10N $l, + ILogger $logger, + IMailer $mailer, + IURLGenerator $urlGenerator, + IManager $activityManager, + SettingsManager $settingsManager, + Defaults $defaults, + IHasher $hasher, + IEventDispatcher $eventDispatcher, + IShareManager $shareManager) { $this->dbConnection = $connection; $this->secureRandom = $secureRandom; $this->userManager = $userManager; @@ -147,6 +150,7 @@ class ShareByMailProvider implements IShareProvider { $this->defaults = $defaults; $this->hasher = $hasher; $this->eventDispatcher = $eventDispatcher; + $this->shareManager = $shareManager; } /** @@ -173,7 +177,7 @@ class ShareByMailProvider implements IShareProvider { // if the admin enforces a password for all mail shares we create a // random password and send it to the recipient $password = $share->getPassword() ?: ''; - $passwordEnforced = $this->settingsManager->enforcePasswordProtection(); + $passwordEnforced = $this->shareManager->shareApiLinkEnforcePassword(); if ($passwordEnforced && empty($password)) { $password = $this->autoGeneratePassword($share); } |