summaryrefslogtreecommitdiffstats
path: root/apps/sharebymail
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2018-07-12 14:55:50 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-07-21 15:02:18 +0200
commita93f2a648b2694dcebc3dffd9ca391c1303ce381 (patch)
tree17540bc009d2f4362bd17439e671b3174a20afa1 /apps/sharebymail
parentcce12f0ca3e2b2b158ffa43450b862053291b8d0 (diff)
downloadnextcloud-server-a93f2a648b2694dcebc3dffd9ca391c1303ce381.tar.gz
nextcloud-server-a93f2a648b2694dcebc3dffd9ca391c1303ce381.zip
allow to add a personal note to a share
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/sharebymail')
-rw-r--r--apps/sharebymail/lib/ShareByMailProvider.php60
1 files changed, 60 insertions, 0 deletions
diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php
index 1a1855b9c44..bf251c627a0 100644
--- a/apps/sharebymail/lib/ShareByMailProvider.php
+++ b/apps/sharebymail/lib/ShareByMailProvider.php
@@ -506,6 +506,61 @@ class ShareByMailProvider implements IShareProvider {
return true;
}
+ protected function sendNote(IShare $share) {
+
+ $recipient = $share->getSharedWith();
+
+
+ $filename = $share->getNode()->getName();
+ $initiator = $share->getSharedBy();
+ $note = $share->getNote();
+
+ $initiatorUser = $this->userManager->get($initiator);
+ $initiatorDisplayName = ($initiatorUser instanceof IUser) ? $initiatorUser->getDisplayName() : $initiator;
+ $initiatorEmailAddress = ($initiatorUser instanceof IUser) ? $initiatorUser->getEMailAddress() : null;
+
+ $plainBodyPart = $this->l->t("%s shared »%s« with you and want to add:\n", [$initiatorDisplayName, $filename]);
+ $htmlBodyPart = $this->l->t('%s shared »%s« with you and want to add:', [$initiatorDisplayName, $filename]);
+
+ $message = $this->mailer->createMessage();
+
+ $emailTemplate = $this->mailer->createEMailTemplate('shareByMail.sendNote', [
+ 'filename' => $filename,
+ 'note' => $note,
+ 'initiator' => $initiatorDisplayName,
+ 'initiatorEmail' => $initiatorEmailAddress,
+ 'shareWith' => $recipient,
+ ]);
+
+ $emailTemplate->setSubject($this->l->t('»%s« added a note to a file shared with you', [$initiatorDisplayName]));
+ $emailTemplate->addHeader();
+ $emailTemplate->addHeading($this->l->t('Note regarding »%s«', [$filename]), false);
+ $emailTemplate->addBodyText(htmlspecialchars($htmlBodyPart), $plainBodyPart);
+ $emailTemplate->addBodyText($note);
+
+ // The "From" contains the sharers name
+ $instanceName = $this->defaults->getName();
+ $senderName = $this->l->t(
+ '%s via %s',
+ [
+ $initiatorDisplayName,
+ $instanceName
+ ]
+ );
+ $message->setFrom([\OCP\Util::getDefaultEmailAddress($instanceName) => $senderName]);
+ if ($initiatorEmailAddress !== null) {
+ $message->setReplyTo([$initiatorEmailAddress => $initiatorDisplayName]);
+ $emailTemplate->addFooter($instanceName . ' - ' . $this->defaults->getSlogan());
+ } else {
+ $emailTemplate->addFooter();
+ }
+
+ $message->setTo([$recipient]);
+ $message->useTemplate($emailTemplate);
+ $this->mailer->send($message);
+
+ }
+
/**
* send auto generated password to the owner. This happens if the admin enforces
* a password for mail shares and forbid to send the password by mail to the recipient
@@ -662,8 +717,13 @@ class ShareByMailProvider implements IShareProvider {
->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()))
->set('password', $qb->createNamedParameter($share->getPassword()))
->set('expiration', $qb->createNamedParameter($share->getExpirationDate(), IQueryBuilder::PARAM_DATE))
+ ->set('note', $qb->createNamedParameter($share->getNote()))
->execute();
+ if ($originalShare->getNote() !== $share->getNote() && $share->getNote() !== '') {
+ $this->sendNote($share);
+ }
+
return $share;
}