diff options
author | Björn Schießle <bjoern@schiessle.org> | 2017-01-16 12:29:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-16 12:29:16 +0100 |
commit | 6c7a7e0c1a9c8c38ed246176ee5c491620d9630c (patch) | |
tree | 2a5544866a9fc860777e1a5fe188521beb10a84b | |
parent | 203436b16be40109131720f06ca39e393c373bae (diff) | |
parent | 27357569b6a3d9c8f635117b5505e2bc5b20d051 (diff) | |
download | nextcloud-server-6c7a7e0c1a9c8c38ed246176ee5c491620d9630c.tar.gz nextcloud-server-6c7a7e0c1a9c8c38ed246176ee5c491620d9630c.zip |
Merge pull request #3033 from nextcloud/share-by-mail-use-display-name
generate correct path for owner and use the display name instead of t…
-rw-r--r-- | apps/sharebymail/lib/ShareByMailProvider.php | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index cb013acd4de..e09ca308f31 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -31,6 +31,7 @@ use OCP\IDBConnection; use OCP\IL10N; use OCP\ILogger; use OCP\IURLGenerator; +use OCP\IUser; use OCP\IUserManager; use OCP\Mail\IMailer; use OCP\Security\ISecureRandom; @@ -167,14 +168,14 @@ class ShareByMailProvider implements IShareProvider { if ($share->getShareOwner() !== $share->getSharedBy()) { $ownerFolder = $this->rootFolder->getUserFolder($share->getShareOwner()); $fileId = $share->getNode()->getId(); - $node = $ownerFolder->getById($fileId); - $ownerPath = $node[0]->getPath(); + $nodes = $ownerFolder->getById($fileId); + $ownerPath = $nodes[0]->getPath(); $this->publishActivity( Activity::SUBJECT_SHARED_EMAIL_BY, [$ownerFolder->getRelativePath($ownerPath), $share->getSharedWith(), $share->getSharedBy()], $share->getShareOwner(), $fileId, - $userFolder->getRelativePath($ownerPath) + $ownerFolder->getRelativePath($ownerPath) ); } @@ -240,15 +241,19 @@ class ShareByMailProvider implements IShareProvider { } protected function sendMailNotification($filename, $link, $owner, $initiator, $shareWith) { + $ownerUser = $this->userManager->get($owner); + $initiatorUser = $this->userManager->get($initiator); + $ownerDisplayName = ($ownerUser instanceof IUser) ? $ownerUser->getDisplayName() : $owner; + $initiatorDisplayName = ($initiatorUser instanceof IUser) ? $initiatorUser->getDisplayName() : $initiator; if ($owner === $initiator) { - $subject = (string)$this->l->t('%s shared »%s« with you', array($owner, $filename)); + $subject = (string)$this->l->t('%s shared »%s« with you', array($ownerDisplayName, $filename)); } else { - $subject = (string)$this->l->t('%s shared »%s« with you on behalf of %s', array($owner, $filename, $initiator)); + $subject = (string)$this->l->t('%s shared »%s« with you on behalf of %s', array($ownerDisplayName, $filename, $initiatorDisplayName)); } $message = $this->mailer->createMessage(); - $htmlBody = $this->createMailBody('mail', $filename, $link, $owner, $initiator); - $textBody = $this->createMailBody('altmail', $filename, $link, $owner, $initiator); + $htmlBody = $this->createMailBody('mail', $filename, $link, $ownerDisplayName, $initiatorDisplayName); + $textBody = $this->createMailBody('altmail', $filename, $link, $ownerDisplayName, $initiatorDisplayName); $message->setTo([$shareWith]); $message->setSubject($subject); $message->setBody($textBody, 'text/plain'); |