diff --git a/lib/Hooks.php b/lib/Hooks.php index 7e1d9d69..8ed6a3e9 100644 --- a/lib/Hooks.php +++ b/lib/Hooks.php @@ -162,8 +162,7 @@ public function handlePostShare(ShareCreatedEvent $event): void { $this->mail->sendGuestInviteMail( $uid, $shareWith, - $share->getNodeType(), - $share->getNodeId(), + $share, $token, $lang ); diff --git a/lib/Mail.php b/lib/Mail.php index 31c422af..5db1acb1 100644 --- a/lib/Mail.php +++ b/lib/Mail.php @@ -84,7 +84,7 @@ public function __construct( * @param $uid * @throws \Exception */ - public function sendGuestInviteMail(string $uid, string $shareWith, string $itemType, string $itemSource, string $token, string $language = ''): void { + public function sendGuestInviteMail(string $uid, string $shareWith, Share\IShare $share, string $token, string $language = ''): void { if ($language === '') { $language = null; } @@ -102,22 +102,12 @@ public function sendGuestInviteMail(string $uid, string $shareWith, string $item $replyTo = $this->userManager->get($uid)->getEMailAddress(); $senderDisplayName = $this->userSession->getUser()->getDisplayName(); - $items = Share::getItemSharedWithUser($itemType, $itemSource, $shareWith); - $filename = trim($items[0]['file_target'], '/'); - $subject = (string)$l10n->t('%s shared »%s« with you', [$senderDisplayName, $filename]); - $expiration = null; - if (isset($items[0]['expiration'])) { - try { - $date = new \DateTime($items[0]['expiration']); - $expiration = $date->getTimestamp(); - } catch (\Exception $e) { - $this->logger->error("Couldn't read date: " . $e->getMessage(), ['app' => 'sharing']); - } - } - + $filename = trim($share->getTarget(), '/'); + $subject = $l10n->t('%s shared »%s« with you', [$senderDisplayName, $filename]); + $expiration = $share->getExpirationDate(); $link = $this->urlGenerator->linkToRouteAbsolute( - 'files.viewcontroller.showFile', ['fileid' => $itemSource] + 'files.viewcontroller.showFile', ['fileid' => $share->getNodeId()] ); $emailTemplate = $this->mailer->createEMailTemplate('guest.invite');