diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2016-07-29 15:38:31 +0200 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2016-11-01 19:51:11 +0100 |
commit | a17c6a485d91bdc1c322a454c66d9d017a5f8ca5 (patch) | |
tree | 96b90220f17bfd7143b10051ab38c4f6e071d56d /lib/private/Share20 | |
parent | 0a6f02801f333c17ca6455906bc816020883477d (diff) | |
download | nextcloud-server-a17c6a485d91bdc1c322a454c66d9d017a5f8ca5.tar.gz nextcloud-server-a17c6a485d91bdc1c322a454c66d9d017a5f8ca5.zip |
add share by mail share provider
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'lib/private/Share20')
-rw-r--r-- | lib/private/Share20/Manager.php | 14 | ||||
-rw-r--r-- | lib/private/Share20/ProviderFactory.php | 38 |
2 files changed, 52 insertions, 0 deletions
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 838650ada15..19d6151a037 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -185,6 +185,10 @@ class Manager implements IManager { if ($share->getSharedWith() === null) { throw new \InvalidArgumentException('SharedWith should not be empty'); } + } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) { + if ($share->getSharedWith() === null) { + throw new \InvalidArgumentException('SharedWith should not be empty'); + } } else { // We can't handle other types yet throw new \InvalidArgumentException('unkown share type'); @@ -580,6 +584,16 @@ class Manager implements IManager { if ($share->getPassword() !== null) { $share->setPassword($this->hasher->hash($share->getPassword())); } + } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) { + $this->linkCreateChecks($share); + $share->setToken( + $this->secureRandom->generate( + \OC\Share\Constants::TOKEN_LENGTH, + \OCP\Security\ISecureRandom::CHAR_LOWER. + \OCP\Security\ISecureRandom::CHAR_UPPER. + \OCP\Security\ISecureRandom::CHAR_DIGITS + ) + ); } // Cannot share with the owner diff --git a/lib/private/Share20/ProviderFactory.php b/lib/private/Share20/ProviderFactory.php index 5cdc9a51a22..e1ed64d66ad 100644 --- a/lib/private/Share20/ProviderFactory.php +++ b/lib/private/Share20/ProviderFactory.php @@ -28,6 +28,7 @@ use OCA\FederatedFileSharing\DiscoveryManager; use OCA\FederatedFileSharing\FederatedShareProvider; use OCA\FederatedFileSharing\Notifications; use OCA\FederatedFileSharing\TokenHandler; +use OCA\ShareByMail\ShareByMailProvider; use OCP\Share\IProviderFactory; use OC\Share20\Exception\ProviderException; use OCP\IServerContainer; @@ -45,6 +46,8 @@ class ProviderFactory implements IProviderFactory { private $defaultProvider = null; /** @var FederatedShareProvider */ private $federatedProvider = null; + /** @var ShareByMailProvider */ + private $shareByMailProvider; /** * IProviderFactory constructor. @@ -126,6 +129,37 @@ class ProviderFactory implements IProviderFactory { } /** + * Create the federated share provider + * + * @return FederatedShareProvider + */ + protected function getShareByMailProvider() { + if ($this->shareByMailProvider === null) { + /* + * Check if the app is enabled + */ + $appManager = $this->serverContainer->getAppManager(); + if (!$appManager->isEnabledForUser('sharebymail')) { + return null; + } + + $l = $this->serverContainer->getL10N('sharebymail'); + + $this->shareByMailProvider = new ShareByMailProvider( + $this->serverContainer->getDatabaseConnection(), + $this->serverContainer->getSecureRandom(), + $this->serverContainer->getUserManager(), + $this->serverContainer->getLazyRootFolder(), + $l, + $this->serverContainer->getLogger() + ); + } + + return $this->shareByMailProvider; + } + + + /** * @inheritdoc */ public function getProvider($id) { @@ -134,6 +168,8 @@ class ProviderFactory implements IProviderFactory { $provider = $this->defaultShareProvider(); } else if ($id === 'ocFederatedSharing') { $provider = $this->federatedShareProvider(); + } else if ($id = 'ocMailShare') { + $provider = $this->getShareByMailProvider(); } if ($provider === null) { @@ -155,6 +191,8 @@ class ProviderFactory implements IProviderFactory { $provider = $this->defaultShareProvider(); } else if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE) { $provider = $this->federatedShareProvider(); + } else if ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) { + $provider = $this->getShareByMailProvider(); } if ($provider === null) { |