diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2017-09-11 00:28:24 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2017-11-27 09:38:39 +0100 |
commit | 56a25125817f4f0172c2310dca719bdcb5cbef8e (patch) | |
tree | ffafa68439a0be9280fb53b2e9f44e0f86c667b9 /lib/private/Share20 | |
parent | 655c0cb40d9db482ef2a546e2b82e5740a2d76c5 (diff) | |
download | nextcloud-server-56a25125817f4f0172c2310dca719bdcb5cbef8e.tar.gz nextcloud-server-56a25125817f4f0172c2310dca719bdcb5cbef8e.zip |
Add support for `\OCP\Share\IShare::getMailSend` back
This adds back the support for `\OCP\Share\IShare::getMailSend`, one example is creating bulk shares via API which where previously blocking due to the share notification emails.
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'lib/private/Share20')
-rw-r--r-- | lib/private/Share20/DefaultShareProvider.php | 2 | ||||
-rw-r--r-- | lib/private/Share20/Manager.php | 39 |
2 files changed, 23 insertions, 18 deletions
diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index a440c36406b..ca0a6349db4 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -837,7 +837,7 @@ class DefaultShareProvider implements IShareProvider { ->setShareType((int)$data['share_type']) ->setPermissions((int)$data['permissions']) ->setTarget($data['file_target']) - ->setMailSend((bool)$data['mail_send']); + ->setMailSend(true); $shareTime = new \DateTime(); $shareTime->setTimestamp((int)$data['stime']); diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 83fe4ec0d19..b22bfbc3878 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -669,26 +669,31 @@ class Manager implements IManager { $this->eventDispatcher->dispatch('OCP\Share::postShare', $event); if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { - $user = $this->userManager->get($share->getSharedWith()); - if ($user !== null) { - $emailAddress = $user->getEMailAddress(); - if ($emailAddress !== null && $emailAddress !== '') { - $userLang = $this->config->getUserValue($share->getSharedWith(), 'core', 'lang', null); - $l = $this->l10nFactory->get('lib', $userLang); - $this->sendMailNotification( - $l, - $share->getNode()->getName(), - $this->urlGenerator->linkToRouteAbsolute('files.viewcontroller.showFile', [ 'fileid' => $share->getNode()->getId() ]), - $share->getSharedBy(), - $emailAddress, - $share->getExpirationDate() - ); - $this->logger->debug('Send share notification to ' . $emailAddress . ' for share with ID ' . $share->getId(), ['app' => 'share']); + $mailSend = $share->getMailSend(); + if($mailSend === true) { + $user = $this->userManager->get($share->getSharedWith()); + if ($user !== null) { + $emailAddress = $user->getEMailAddress(); + if ($emailAddress !== null && $emailAddress !== '') { + $userLang = $this->config->getUserValue($share->getSharedWith(), 'core', 'lang', null); + $l = $this->l10nFactory->get('lib', $userLang); + $this->sendMailNotification( + $l, + $share->getNode()->getName(), + $this->urlGenerator->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $share->getNode()->getId()]), + $share->getSharedBy(), + $emailAddress, + $share->getExpirationDate() + ); + $this->logger->debug('Send share notification to ' . $emailAddress . ' for share with ID ' . $share->getId(), ['app' => 'share']); + } else { + $this->logger->debug('Share notification not send to ' . $share->getSharedWith() . ' because email address is not set.', ['app' => 'share']); + } } else { - $this->logger->debug('Share notification not send to ' . $share->getSharedWith() . ' because email address is not set.', ['app' => 'share']); + $this->logger->debug('Share notification not send to ' . $share->getSharedWith() . ' because user could not be found.', ['app' => 'share']); } } else { - $this->logger->debug('Share notification not send to ' . $share->getSharedWith() . ' because user could not be found.', ['app' => 'share']); + $this->logger->debug('Share notification not send because mailsend is false.', ['app' => 'share']); } } |