Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(share): Don't print twice the same text on emails #49746

Merged
merged 1 commit into from
Dec 11, 2024
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
4 changes: 1 addition & 3 deletions apps/sharebymail/lib/ShareByMailProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ protected function sendEmail(IShare $share, array $emails): void {
$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]);

if ($note !== '') {
$emailTemplate->addBodyListItem(
Expand All @@ -354,8 +353,7 @@ protected function sendEmail(IShare $share, array $emails): void {
}

$emailTemplate->addBodyText(
htmlspecialchars($text . ' ' . $this->l->t('Click the button below to open it.')),
$text
$this->l->t('Click the button below to open it.')
come-nc marked this conversation as resolved.
Show resolved Hide resolved
);

$emailTemplate->addBodyButton(
Expand Down
24 changes: 6 additions & 18 deletions apps/sharebymail/tests/ShareByMailProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1292,10 +1292,7 @@ public function testSendMailNotificationWithSameUserAndUserEmail(): void {
$template
->expects($this->once())
->method('addBodyText')
->with(
'Mrs. Owner User shared file.txt with you. Click the button below to open it.',
'Mrs. Owner User shared file.txt with you.'
);
->with('Click the button below to open it.');
$template
->expects($this->once())
->method('addBodyButton')
Expand Down Expand Up @@ -1405,7 +1402,7 @@ public function testSendMailNotificationWithSameUserAndUserEmailAndNote(): void
$template
->expects($this->once())
->method('addBodyText')
->with('Mrs. Owner User shared file.txt with you. Click the button below to open it.', 'Mrs. Owner User shared file.txt with you.');
->with('Click the button below to open it.');

$this->urlGenerator->expects($this->once())->method('imagePath')
->with('core', 'caldav/description.png')
Expand Down Expand Up @@ -1531,7 +1528,7 @@ public function testSendMailNotificationWithSameUserAndUserEmailAndExpiration():
$template
->expects($this->once())
->method('addBodyText')
->with('Mrs. Owner User shared file.txt with you. Click the button below to open it.', 'Mrs. Owner User shared file.txt with you.');
->with('Click the button below to open it.');

$expiration = new DateTime('2001-01-01');
$this->l->expects($this->once())
Expand Down Expand Up @@ -1663,10 +1660,7 @@ public function testSendMailNotificationWithDifferentUserAndNoUserEmail(): void
$template
->expects($this->once())
->method('addBodyText')
->with(
'Mr. Initiator User shared file.txt with you. Click the button below to open it.',
'Mr. Initiator User shared file.txt with you.'
);
->with('Click the button below to open it.');
$template
->expects($this->once())
->method('addBodyButton')
Expand Down Expand Up @@ -1767,10 +1761,7 @@ public function testSendMailNotificationWithSameUserAndUserEmailAndReplyToDesact
$template
->expects($this->once())
->method('addBodyText')
->with(
'Mrs. Owner User shared file.txt with you. Click the button below to open it.',
'Mrs. Owner User shared file.txt with you.'
);
->with('Click the button below to open it.');
$template
->expects($this->once())
->method('addBodyButton')
Expand Down Expand Up @@ -1875,10 +1866,7 @@ public function testSendMailNotificationWithDifferentUserAndNoUserEmailAndReplyT
$template
->expects($this->once())
->method('addBodyText')
->with(
'Mr. Initiator User shared file.txt with you. Click the button below to open it.',
'Mr. Initiator User shared file.txt with you.'
);
->with('Click the button below to open it.');
$template
->expects($this->once())
->method('addBodyButton')
Expand Down
19 changes: 9 additions & 10 deletions lib/private/Share20/DefaultShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -1512,21 +1512,20 @@ protected function sendUserShareMail(
'shareWith' => $shareWith,
]);

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

if ($note !== '') {
$emailTemplate->addBodyText(htmlspecialchars($note), $note);
}

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

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

Expand Down Expand Up @@ -1601,20 +1600,20 @@ private function sendNote(array $recipients, IShare $share) {
$initiatorUser = $this->userManager->get($initiator);
$initiatorDisplayName = ($initiatorUser instanceof IUser) ? $initiatorUser->getDisplayName() : $initiator;
$initiatorEmailAddress = ($initiatorUser instanceof IUser) ? $initiatorUser->getEMailAddress() : null;
$plainHeading = $l->t('%1$s shared »%2$s« with you and wants to add:', [$initiatorDisplayName, $filename]);
$htmlHeading = $l->t('%1$s shared »%2$s« with you and wants to add', [$initiatorDisplayName, $filename]);
$plainHeading = $l->t('%1$s shared %2$s with you and wants to add:', [$initiatorDisplayName, $filename]);
$htmlHeading = $l->t('%1$s shared %2$s with you and wants to add', [$initiatorDisplayName, $filename]);
$message = $this->mailer->createMessage();

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

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

$link = $this->urlGenerator->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $share->getNode()->getId()]);
$emailTemplate->addBodyButton(
$l->t('Open »%s«', [$filename]),
$l->t('Open %s', [$filename]),
$link
);

Expand Down
Loading