diff options
author | Simon L <szaimen@e.mail.de> | 2023-03-16 12:26:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-16 12:26:12 +0100 |
commit | 0e5fcb49d4b90d0ec57cbff7ff9b2c4810583b37 (patch) | |
tree | c5e64dae0ae109cc47260b733e2c81fc0a8220b5 | |
parent | ad2e242458f9f5dbe9d042caf616c30475027966 (diff) | |
parent | 944efa388aed137937dfd21ef795d83a9b2b2ce7 (diff) | |
download | nextcloud-server-0e5fcb49d4b90d0ec57cbff7ff9b2c4810583b37.tar.gz nextcloud-server-0e5fcb49d4b90d0ec57cbff7ff9b2c4810583b37.zip |
Merge pull request #36661 from onny/event-update-mail-subject
Invitation mail: Change subject if event got updated
-rw-r--r-- | apps/dav/lib/CalDAV/Schedule/IMipPlugin.php | 3 | ||||
-rw-r--r-- | apps/dav/lib/CalDAV/Schedule/IMipService.php | 7 | ||||
-rw-r--r-- | apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php | 10 |
3 files changed, 13 insertions, 7 deletions
diff --git a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php index ca79205c09f..76e84a2b54b 100644 --- a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php +++ b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php @@ -183,6 +183,7 @@ class IMipPlugin extends SabreIMipPlugin { $vEvent = array_pop($modified['new']); /** @var VEvent $oldVevent */ $oldVevent = !empty($modified['old']) && is_array($modified['old']) ? array_pop($modified['old']) : null; + $isModified = isset($oldVevent); // No changed events after all - this shouldn't happen if there is significant change yet here we are // The scheduling status is debatable @@ -255,7 +256,7 @@ class IMipPlugin extends SabreIMipPlugin { $template = $this->mailer->createEMailTemplate('dav.calendarInvite.' . $method, $data); $template->addHeader(); - $this->imipService->addSubjectAndHeading($template, $method, $data['invitee_name'], $data['meeting_title']); + $this->imipService->addSubjectAndHeading($template, $method, $data['invitee_name'], $data['meeting_title'], $isModified); $this->imipService->addBulletList($template, $vEvent, $data); // Only add response buttons to invitation requests: Fix Issue #11230 diff --git a/apps/dav/lib/CalDAV/Schedule/IMipService.php b/apps/dav/lib/CalDAV/Schedule/IMipService.php index 50e770e6b40..3a624bca4bc 100644 --- a/apps/dav/lib/CalDAV/Schedule/IMipService.php +++ b/apps/dav/lib/CalDAV/Schedule/IMipService.php @@ -363,9 +363,10 @@ class IMipService { * @param string $sender * @param string $summary * @param string|null $partstat + * @param bool $isModified */ public function addSubjectAndHeading(IEMailTemplate $template, - string $method, string $sender, string $summary): void { + string $method, string $sender, string $summary, bool $isModified): void { if ($method === IMipPlugin::METHOD_CANCEL) { // TRANSLATORS Subject for email, when an invitation is cancelled. Ex: "Cancelled: {{Event Name}}" $template->setSubject($this->l10n->t('Cancelled: %1$s', [$summary])); @@ -374,6 +375,10 @@ class IMipService { // TRANSLATORS Subject for email, when an invitation is replied to. Ex: "Re: {{Event Name}}" $template->setSubject($this->l10n->t('Re: %1$s', [$summary])); $template->addHeading($this->l10n->t('%1$s has responded to your invitation', [$sender])); + } elseif ($method === IMipPlugin::METHOD_REQUEST && $isModified) { + // TRANSLATORS Subject for email, when an invitation is updated. Ex: "Invitation updated: {{Event Name}}" + $template->setSubject($this->l10n->t('Invitation updated: %1$s', [$summary])); + $template->addHeading($this->l10n->t('%1$s updated the event "%2$s"', [$sender, $summary])); } else { // TRANSLATORS Subject for email, when an invitation is sent. Ex: "Invitation: {{Event Name}}" $template->setSubject($this->l10n->t('Invitation: %1$s', [$summary])); diff --git a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php index fdd707247ac..bf28fb472a8 100644 --- a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php +++ b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php @@ -204,7 +204,7 @@ class IMipPluginTest extends TestCase { ->method('getFrom'); $this->service->expects(self::once()) ->method('addSubjectAndHeading') - ->with($this->emailTemplate, 'request', 'Mr. Wizard', 'Fellowship meeting without (!) Boromir'); + ->with($this->emailTemplate, 'request', 'Mr. Wizard', 'Fellowship meeting without (!) Boromir', true); $this->service->expects(self::once()) ->method('addBulletList') ->with($this->emailTemplate, $newVevent, $data); @@ -296,7 +296,7 @@ class IMipPluginTest extends TestCase { ->method('getFrom'); $this->service->expects(self::once()) ->method('addSubjectAndHeading') - ->with($this->emailTemplate, 'request', 'Mr. Wizard', 'Elevenses'); + ->with($this->emailTemplate, 'request', 'Mr. Wizard', 'Elevenses', false); $this->service->expects(self::once()) ->method('addBulletList') ->with($this->emailTemplate, $newVevent, $data); @@ -405,7 +405,7 @@ class IMipPluginTest extends TestCase { ->method('getFrom'); $this->service->expects(self::once()) ->method('addSubjectAndHeading') - ->with($this->emailTemplate, 'request', 'Mr. Wizard', 'Fellowship meeting without (!) Boromir'); + ->with($this->emailTemplate, 'request', 'Mr. Wizard', 'Fellowship meeting without (!) Boromir', false); $this->service->expects(self::once()) ->method('addBulletList') ->with($this->emailTemplate, $newVevent, $data); @@ -480,7 +480,7 @@ class IMipPluginTest extends TestCase { ->method('getFrom'); $this->service->expects(self::once()) ->method('addSubjectAndHeading') - ->with($this->emailTemplate, 'request', 'Mr. Wizard', 'Fellowship meeting'); + ->with($this->emailTemplate, 'request', 'Mr. Wizard', 'Fellowship meeting', false); $this->service->expects(self::once()) ->method('addBulletList') ->with($this->emailTemplate, $newVevent, $data); @@ -553,7 +553,7 @@ class IMipPluginTest extends TestCase { ->method('getFrom'); $this->service->expects(self::once()) ->method('addSubjectAndHeading') - ->with($this->emailTemplate, 'request', 'Mr. Wizard', 'Fellowship meeting'); + ->with($this->emailTemplate, 'request', 'Mr. Wizard', 'Fellowship meeting', false); $this->service->expects(self::once()) ->method('addBulletList') ->with($this->emailTemplate, $newVevent, $data); |