From 42eb67fdd1b6bed0ca1e0bb5e5ac42c52b3ab05a Mon Sep 17 00:00:00 2001 From: Luc DUZAN Date: Wed, 21 Dec 2016 09:23:01 +0100 Subject: [PATCH] 358 Bugfix Broker::processMessageReply Before this commit processMessageReply did not work for exceptions with a reccurent id in an other timezone than the dtstart of the master event. --- lib/ITip/Broker.php | 19 +-- tests/VObject/ITip/BrokerProcessReplyTest.php | 123 ++++++++++++++++++ 2 files changed, 134 insertions(+), 8 deletions(-) diff --git a/lib/ITip/Broker.php b/lib/ITip/Broker.php index 9cbc3f72b..aa0bdee2c 100644 --- a/lib/ITip/Broker.php +++ b/lib/ITip/Broker.php @@ -335,7 +335,10 @@ protected function processMessageReply(Message $itipMessage, ?VCalendar $existin foreach ($itipMessage->message->VEVENT as $vevent) { $recurId = isset($vevent->{'RECURRENCE-ID'}) ? $vevent->{'RECURRENCE-ID'}->getValue() : 'master'; $attendee = $vevent->ATTENDEE; - $instances[$recurId] = $attendee['PARTSTAT']->getValue(); + $instances[$recurId] = [ + 'partstat' => $attendee['PARTSTAT']->getValue(), + 'recurIdDateTime' => isset($vevent->{'RECURRENCE-ID'}) ? $vevent->{'RECURRENCE-ID'}->getDateTime() : null, + ]; if (isset($vevent->{'REQUEST-STATUS'})) { $requestStatus = $vevent->{'REQUEST-STATUS'}->getValue(); list($requestStatus) = explode(';', $requestStatus); @@ -356,7 +359,7 @@ protected function processMessageReply(Message $itipMessage, ?VCalendar $existin foreach ($vevent->ATTENDEE as $attendee) { if ($attendee->getValue() === $itipMessage->sender) { $attendeeFound = true; - $attendee['PARTSTAT'] = $instances[$recurId]; + $attendee['PARTSTAT'] = $instances[$recurId]['partstat']; $attendee['SCHEDULE-STATUS'] = $requestStatus; // Un-setting the RSVP status, because we now know // that the attendee already replied. @@ -369,7 +372,7 @@ protected function processMessageReply(Message $itipMessage, ?VCalendar $existin // Adding a new attendee. The iTip documentation calls this // a party crasher. $attendee = $vevent->add('ATTENDEE', $itipMessage->sender, [ - 'PARTSTAT' => $instances[$recurId], + 'PARTSTAT' => $instances[$recurId]['partstat'], ]); if ($itipMessage->senderName) { $attendee['CN'] = $itipMessage->senderName; @@ -385,15 +388,15 @@ protected function processMessageReply(Message $itipMessage, ?VCalendar $existin } // If we got replies to instances that did not exist in the // original list, it means that new exceptions must be created. - foreach ($instances as $recurId => $partstat) { + foreach ($instances as $recurId => $instance) { $recurrenceIterator = new EventIterator($existingObject, $itipMessage->uid); $found = false; $iterations = 1000; + $recurIdDate = $instance['recurIdDateTime']; do { $newObject = $recurrenceIterator->getEventObject(); $recurrenceIterator->next(); - - if (isset($newObject->{'RECURRENCE-ID'}) && $newObject->{'RECURRENCE-ID'}->getValue() === $recurId) { + if (isset($newObject->{'RECURRENCE-ID'}) && $newObject->{'RECURRENCE-ID'}->getDateTime() == $recurIdDate) { $found = true; } --$iterations; @@ -414,7 +417,7 @@ protected function processMessageReply(Message $itipMessage, ?VCalendar $existin foreach ($newObject->ATTENDEE as $attendee) { if ($attendee->getValue() === $itipMessage->sender) { $attendeeFound = true; - $attendee['PARTSTAT'] = $partstat; + $attendee['PARTSTAT'] = $instance['partstat']; break; } } @@ -422,7 +425,7 @@ protected function processMessageReply(Message $itipMessage, ?VCalendar $existin if (!$attendeeFound) { // Adding a new attendee $attendee = $newObject->add('ATTENDEE', $itipMessage->sender, [ - 'PARTSTAT' => $partstat, + 'PARTSTAT' => $instance['partstat'], ]); if ($itipMessage->senderName) { $attendee['CN'] = $itipMessage->senderName; diff --git a/tests/VObject/ITip/BrokerProcessReplyTest.php b/tests/VObject/ITip/BrokerProcessReplyTest.php index 064d5cb48..7b46acaec 100644 --- a/tests/VObject/ITip/BrokerProcessReplyTest.php +++ b/tests/VObject/ITip/BrokerProcessReplyTest.php @@ -373,6 +373,129 @@ public function testReplyNewExceptionTz(): void $this->process($itip, $old, $expected); } + public function testReplyNewExceptionReccurenceIdInDifferentTz(): void + { + // This is a reply to 1 instance of a recurring event. This should + // automatically create an exception. + $itip = <<process($itip, $old, $expected); + } + + /** + * @group failing + */ + public function testReplyNewExceptionReccurenceIdInUTC(): void + { + // This is a reply to 1 instance of a recurring event. This should + // automatically create an exception. + $itip = <<process($itip, $old, $expected); + } + public function testReplyPartyCrashCreateException(): void { // IN this test there's a recurring event that has an exception. The