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>
This commit is contained in:
Lukas Reschke 2017-09-11 00:28:24 +02:00 committed by Morris Jobke
parent 655c0cb40d
commit 56a2512581
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
2 changed files with 23 additions and 18 deletions

View File

@ -837,7 +837,7 @@ class DefaultShareProvider implements IShareProvider {
->setShareType((int)$data['share_type']) ->setShareType((int)$data['share_type'])
->setPermissions((int)$data['permissions']) ->setPermissions((int)$data['permissions'])
->setTarget($data['file_target']) ->setTarget($data['file_target'])
->setMailSend((bool)$data['mail_send']); ->setMailSend(true);
$shareTime = new \DateTime(); $shareTime = new \DateTime();
$shareTime->setTimestamp((int)$data['stime']); $shareTime->setTimestamp((int)$data['stime']);

View File

@ -669,26 +669,31 @@ class Manager implements IManager {
$this->eventDispatcher->dispatch('OCP\Share::postShare', $event); $this->eventDispatcher->dispatch('OCP\Share::postShare', $event);
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
$user = $this->userManager->get($share->getSharedWith()); $mailSend = $share->getMailSend();
if ($user !== null) { if($mailSend === true) {
$emailAddress = $user->getEMailAddress(); $user = $this->userManager->get($share->getSharedWith());
if ($emailAddress !== null && $emailAddress !== '') { if ($user !== null) {
$userLang = $this->config->getUserValue($share->getSharedWith(), 'core', 'lang', null); $emailAddress = $user->getEMailAddress();
$l = $this->l10nFactory->get('lib', $userLang); if ($emailAddress !== null && $emailAddress !== '') {
$this->sendMailNotification( $userLang = $this->config->getUserValue($share->getSharedWith(), 'core', 'lang', null);
$l, $l = $this->l10nFactory->get('lib', $userLang);
$share->getNode()->getName(), $this->sendMailNotification(
$this->urlGenerator->linkToRouteAbsolute('files.viewcontroller.showFile', [ 'fileid' => $share->getNode()->getId() ]), $l,
$share->getSharedBy(), $share->getNode()->getName(),
$emailAddress, $this->urlGenerator->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $share->getNode()->getId()]),
$share->getExpirationDate() $share->getSharedBy(),
); $emailAddress,
$this->logger->debug('Send share notification to ' . $emailAddress . ' for share with ID ' . $share->getId(), ['app' => 'share']); $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 { } 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 { } 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']);
} }
} }