From 0011d83bccbd4a9d0a225d5be61e016ca24d807f Mon Sep 17 00:00:00 2001 From: Git'Fellow <12234510+solracsf@users.noreply.github.com> Date: Tue, 10 Dec 2024 09:39:00 +0100 Subject: [PATCH] fix(share): Don't print twice the same information Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com> --- apps/sharebymail/lib/ShareByMailProvider.php | 4 +--- .../tests/ShareByMailProviderTest.php | 24 +++++-------------- lib/private/Share20/DefaultShareProvider.php | 19 +++++++-------- 3 files changed, 16 insertions(+), 31 deletions(-) diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index fd84412882792..d159e4ef5e09f 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -331,7 +331,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( @@ -352,8 +351,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.') ); $emailTemplate->addBodyButton( diff --git a/apps/sharebymail/tests/ShareByMailProviderTest.php b/apps/sharebymail/tests/ShareByMailProviderTest.php index ae5d768b624ea..92219a7e9bb9e 100644 --- a/apps/sharebymail/tests/ShareByMailProviderTest.php +++ b/apps/sharebymail/tests/ShareByMailProviderTest.php @@ -1305,10 +1305,7 @@ public function testSendMailNotificationWithSameUserAndUserEmail() { $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') @@ -1418,7 +1415,7 @@ public function testSendMailNotificationWithSameUserAndUserEmailAndNote() { $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') @@ -1544,7 +1541,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()) @@ -1676,10 +1673,7 @@ public function testSendMailNotificationWithDifferentUserAndNoUserEmail() { $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') @@ -1780,10 +1774,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') @@ -1888,10 +1879,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') diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index e0ff2ff703858..00b8ed8070def 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -1507,21 +1507,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 ); @@ -1596,20 +1595,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 );