mirror of
https://github.com/nextcloud/server.git
synced 2026-04-24 07:39:23 -04:00
fix(dav): Parse sender PARTSTAT in REPLYs
Signed-off-by: Anna Larch <anna@nextcloud.com>
This commit is contained in:
parent
f37b29eb2d
commit
fd85c86cde
2 changed files with 35 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue