diff options
author | Anna Larch <anna@nextcloud.com> | 2023-04-07 15:07:20 +0200 |
---|---|---|
committer | Anna Larch <anna@nextcloud.com> | 2023-04-13 18:55:08 +0200 |
commit | fd85c86cde545be9a62acdad71ea6249f101ae56 (patch) | |
tree | 57c2a53b3d921530e85ba2684b74631e1b026731 | |
parent | f37b29eb2da66c66fd3752209c9e552948e35ca1 (diff) | |
download | nextcloud-server-fd85c86cde545be9a62acdad71ea6249f101ae56.tar.gz nextcloud-server-fd85c86cde545be9a62acdad71ea6249f101ae56.zip |
fix(dav): Parse sender PARTSTAT in REPLYs
Signed-off-by: Anna Larch <anna@nextcloud.com>
-rw-r--r-- | apps/dav/lib/CalDAV/Schedule/IMipPlugin.php | 4 | ||||
-rw-r--r-- | apps/dav/lib/CalDAV/Schedule/IMipService.php | 34 |
2 files changed, 35 insertions, 3 deletions
diff --git a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php index 76e84a2b54b..329197445dd 100644 --- a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php +++ b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php @@ -217,10 +217,12 @@ class IMipPlugin extends SabreIMipPlugin { $sender = substr($iTipMessage->sender, 7); + $replyingAttendee = null; switch (strtolower($iTipMessage->method)) { case self::METHOD_REPLY: $method = self::METHOD_REPLY; $data = $this->imipService->buildBodyData($vEvent, $oldVevent); + $replyingAttendee = $this->imipService->getReplyingAttendee($iTipMessage); break; case self::METHOD_CANCEL: $method = self::METHOD_CANCEL; @@ -256,7 +258,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'], $isModified); + $this->imipService->addSubjectAndHeading($template, $method, $data['invitee_name'], $data['meeting_title'], $isModified, $replyingAttendee); $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 034a59a98d4..8596500f320 100644 --- a/apps/dav/lib/CalDAV/Schedule/IMipService.php +++ b/apps/dav/lib/CalDAV/Schedule/IMipService.php @@ -366,7 +366,7 @@ class IMipService { * @param bool $isModified */ public function addSubjectAndHeading(IEMailTemplate $template, - string $method, string $sender, string $summary, bool $isModified): void { + string $method, string $sender, string $summary, bool $isModified, ?Property $replyingAttendee = null): 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,7 +374,24 @@ class IMipService { } elseif ($method === IMipPlugin::METHOD_REPLY) { // 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])); + // Build the strings + $partstat = (isset($replyingAttendee)) ? $replyingAttendee->offsetGet('PARTSTAT') : null; + $partstat = ($partstat instanceof Parameter) ? $partstat->getValue() : null; + switch ($partstat) { + case 'ACCEPTED': + $template->addHeading($this->l10n->t('%1$s has accepted your invitation', [$sender])); + break; + case 'TENTATIVE': + $template->addHeading($this->l10n->t('%1$s has tentatively accepted your invitation', [$sender])); + break; + case 'DECLINED': + $template->addHeading($this->l10n->t('%1$s has declined your invitation', [$sender])); + break; + case null: + default: + $template->addHeading($this->l10n->t('%1$s has responded to your invitation', [$sender])); + break; + } } 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])); @@ -603,4 +620,17 @@ class IMipService { $template->addBodyText($html, $text); } + + public function getReplyingAttendee(Message $iTipMessage): ?Property { + /** @var VEvent $vevent */ + $vevent = $iTipMessage->message->VEVENT; + $attendees = $vevent->select('ATTENDEE'); + foreach ($attendees as $attendee) { + /** @var Property $attendee */ + if (strcasecmp($attendee->getValue(), $iTipMessage->sender) === 0) { + return $attendee; + } + } + return null; + } } |