Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions apps/settings/tests/Mailer/NewUserMailHelperTest.php

Large diffs are not rendered by default.

53 changes: 37 additions & 16 deletions apps/sharebymail/lib/ShareByMailProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,21 +328,36 @@ protected function sendEmail(IShare $share, array $emails): void {
'note' => $note
]);

$emailTemplate->setSubject($this->l->t('%1$s shared »%2$s« with you', [$initiatorDisplayName, $filename]));
$emailTemplate->setSubject($this->l->t('%1$s shared %2$s with you', [$initiatorDisplayName, $filename]));
$emailTemplate->addHeader();
$emailTemplate->addHeading($this->l->t('%1$s shared »%2$s« with you', [$initiatorDisplayName, $filename]), false);
$text = $this->l->t('%1$s shared »%2$s« with you.', [$initiatorDisplayName, $filename]);
$emailTemplate->addHeading($this->l->t('%1$s shared %2$s with you', [$initiatorDisplayName, $filename]), false);
$text = $this->l->t('%1$s shared %2$s with you.', [$initiatorDisplayName, $filename]);

if ($note !== '') {
$emailTemplate->addBodyText(htmlspecialchars($note), $note);
$emailTemplate->addBodyListItem(
htmlspecialchars($note),
$this->l->t('Note:'),
$this->getAbsoluteImagePath('caldav/description.png'),
$note
);
}

if ($expiration !== null) {
$dateString = (string)$this->l->l('date', $expiration, ['width' => 'medium']);
$emailTemplate->addBodyListItem(
$this->l->t('This share is valid until %s at midnight', [$dateString]),
$this->l->t('Expiration:'),
$this->getAbsoluteImagePath('caldav/time.png'),
);
}

$emailTemplate->addBodyText(
htmlspecialchars($text . ' ' . $this->l->t('Click the button below to open it.')),
$text
);

$emailTemplate->addBodyButton(
$this->l->t('Open »%s«', [$filename]),
$this->l->t('Open %s', [$filename]),
$link
);

Expand Down Expand Up @@ -415,8 +430,8 @@ protected function sendPassword(IShare $share, string $password, array $emails):
$initiatorDisplayName = ($initiatorUser instanceof IUser) ? $initiatorUser->getDisplayName() : $initiator;
$initiatorEmailAddress = ($initiatorUser instanceof IUser) ? $initiatorUser->getEMailAddress() : null;

$plainBodyPart = $this->l->t("%1\$s shared »%2\$s« with you.\nYou should have already received a separate mail with a link to access it.\n", [$initiatorDisplayName, $filename]);
$htmlBodyPart = $this->l->t('%1$s shared »%2$s« with you. You should have already received a separate mail with a link to access it.', [$initiatorDisplayName, $filename]);
$plainBodyPart = $this->l->t("%1\$s shared %2\$s with you.\nYou should have already received a separate mail with a link to access it.\n", [$initiatorDisplayName, $filename]);
$htmlBodyPart = $this->l->t('%1$s shared %2$s with you. You should have already received a separate mail with a link to access it.', [$initiatorDisplayName, $filename]);

$message = $this->mailer->createMessage();

Expand All @@ -428,9 +443,9 @@ protected function sendPassword(IShare $share, string $password, array $emails):
'shareWith' => $shareWith,
]);

$emailTemplate->setSubject($this->l->t('Password to access »%1$s« shared to you by %2$s', [$filename, $initiatorDisplayName]));
$emailTemplate->setSubject($this->l->t('Password to access %1$s shared to you by %2$s', [$filename, $initiatorDisplayName]));
$emailTemplate->addHeader();
$emailTemplate->addHeading($this->l->t('Password to access »%s«', [$filename]), false);
$emailTemplate->addHeading($this->l->t('Password to access %s', [$filename]), false);
$emailTemplate->addBodyText(htmlspecialchars($htmlBodyPart), $plainBodyPart);
$emailTemplate->addBodyText($this->l->t('It is protected with the following password:'));
$emailTemplate->addBodyText($password);
Expand Down Expand Up @@ -501,22 +516,22 @@ protected function sendNote(IShare $share): void {
$initiatorDisplayName = ($initiatorUser instanceof IUser) ? $initiatorUser->getDisplayName() : $initiator;
$initiatorEmailAddress = ($initiatorUser instanceof IUser) ? $initiatorUser->getEMailAddress() : null;

$plainHeading = $this->l->t('%1$s shared »%2$s« with you and wants to add:', [$initiatorDisplayName, $filename]);
$htmlHeading = $this->l->t('%1$s shared »%2$s« with you and wants to add', [$initiatorDisplayName, $filename]);
$plainHeading = $this->l->t('%1$s shared %2$s with you and wants to add:', [$initiatorDisplayName, $filename]);
$htmlHeading = $this->l->t('%1$s shared %2$s with you and wants to add', [$initiatorDisplayName, $filename]);

$message = $this->mailer->createMessage();

$emailTemplate = $this->mailer->createEMailTemplate('shareByMail.sendNote');

$emailTemplate->setSubject($this->l->t('»%s« added a note to a file shared with you', [$initiatorDisplayName]));
$emailTemplate->setSubject($this->l->t('%s added a note to a file shared with you', [$initiatorDisplayName]));
$emailTemplate->addHeader();
$emailTemplate->addHeading(htmlspecialchars($htmlHeading), $plainHeading);
$emailTemplate->addBodyText(htmlspecialchars($note), $note);

$link = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.showShare',
['token' => $share->getToken()]);
$emailTemplate->addBodyButton(
$this->l->t('Open »%s«', [$filename]),
$this->l->t('Open %s', [$filename]),
$link
);

Expand Down Expand Up @@ -564,7 +579,7 @@ protected function sendPasswordToOwner(IShare $share, string $password): bool {
);
}

$bodyPart = $this->l->t('You just shared »%1$s« with %2$s. The share was already sent to the recipient. Due to the security policies defined by the administrator of %3$s each share needs to be protected by password and it is not allowed to send the password directly to the recipient. Therefore you need to forward the password manually to the recipient.', [$filename, $shareWith, $this->defaults->getName()]);
$bodyPart = $this->l->t('You just shared %1$s with %2$s. The share was already sent to the recipient. Due to the security policies defined by the administrator of %3$s each share needs to be protected by password and it is not allowed to send the password directly to the recipient. Therefore you need to forward the password manually to the recipient.', [$filename, $shareWith, $this->defaults->getName()]);

$message = $this->mailer->createMessage();
$emailTemplate = $this->mailer->createEMailTemplate('sharebymail.OwnerPasswordNotification', [
Expand All @@ -575,9 +590,9 @@ protected function sendPasswordToOwner(IShare $share, string $password): bool {
'shareWith' => $shareWith,
]);

$emailTemplate->setSubject($this->l->t('Password to access »%1$s« shared by you with %2$s', [$filename, $shareWith]));
$emailTemplate->setSubject($this->l->t('Password to access %1$s shared by you with %2$s', [$filename, $shareWith]));
$emailTemplate->addHeader();
$emailTemplate->addHeading($this->l->t('Password to access »%s«', [$filename]), false);
$emailTemplate->addHeading($this->l->t('Password to access %s', [$filename]), false);
$emailTemplate->addBodyText($bodyPart);
$emailTemplate->addBodyText($this->l->t('This is the password:'));
$emailTemplate->addBodyText($password);
Expand Down Expand Up @@ -611,6 +626,12 @@ protected function sendPasswordToOwner(IShare $share, string $password): bool {
return true;
}

private function getAbsoluteImagePath(string $path):string {
return $this->urlGenerator->getAbsoluteURL(
$this->urlGenerator->imagePath('core', $path)
);
}

/**
* generate share token
*/
Expand Down
Loading