From 2a653373602572daee01b461b38a618addbc1b9a Mon Sep 17 00:00:00 2001 From: Gregor Harlan Date: Wed, 8 May 2024 10:37:50 +0200 Subject: [PATCH] ITip\Broker: handle timezones in replies to exception events Co-authored-by: Luc DUZAN --- lib/ITip/Broker.php | 6 +- tests/VObject/ITip/BrokerProcessReplyTest.php | 189 ++++++++++++++++++ 2 files changed, 192 insertions(+), 3 deletions(-) diff --git a/lib/ITip/Broker.php b/lib/ITip/Broker.php index 9cbc3f72b..07f53c598 100644 --- a/lib/ITip/Broker.php +++ b/lib/ITip/Broker.php @@ -333,7 +333,7 @@ protected function processMessageReply(Message $itipMessage, ?VCalendar $existin // Finding all the instances the attendee replied to. foreach ($itipMessage->message->VEVENT as $vevent) { - $recurId = isset($vevent->{'RECURRENCE-ID'}) ? $vevent->{'RECURRENCE-ID'}->getValue() : 'master'; + $recurId = isset($vevent->{'RECURRENCE-ID'}) ? $vevent->{'RECURRENCE-ID'}->getDateTime()->getTimestamp() : 'master'; $attendee = $vevent->ATTENDEE; $instances[$recurId] = $attendee['PARTSTAT']->getValue(); if (isset($vevent->{'REQUEST-STATUS'})) { @@ -346,7 +346,7 @@ protected function processMessageReply(Message $itipMessage, ?VCalendar $existin // all the instances where we have a reply for. $masterObject = null; foreach ($existingObject->VEVENT as $vevent) { - $recurId = isset($vevent->{'RECURRENCE-ID'}) ? $vevent->{'RECURRENCE-ID'}->getValue() : 'master'; + $recurId = isset($vevent->{'RECURRENCE-ID'}) ? $vevent->{'RECURRENCE-ID'}->getDateTime()->getTimestamp() : 'master'; if ('master' === $recurId) { $masterObject = $vevent; } @@ -393,7 +393,7 @@ protected function processMessageReply(Message $itipMessage, ?VCalendar $existin $newObject = $recurrenceIterator->getEventObject(); $recurrenceIterator->next(); - if (isset($newObject->{'RECURRENCE-ID'}) && $newObject->{'RECURRENCE-ID'}->getValue() === $recurId) { + if (isset($newObject->{'RECURRENCE-ID'}) && $newObject->{'RECURRENCE-ID'}->getDateTime()->getTimestamp() === $recurId) { $found = true; } --$iterations; diff --git a/tests/VObject/ITip/BrokerProcessReplyTest.php b/tests/VObject/ITip/BrokerProcessReplyTest.php index 064d5cb48..19b668818 100644 --- a/tests/VObject/ITip/BrokerProcessReplyTest.php +++ b/tests/VObject/ITip/BrokerProcessReplyTest.php @@ -253,6 +253,75 @@ public function testReplyPartyCrasher(): void $this->process($itip, $old, $expected); } + public function testReplyExistingExceptionRecurrenceIdInUTC(): 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 testReplyNewException(): void { // This is a reply to 1 instance of a recurring event. This should @@ -373,6 +442,126 @@ public function testReplyNewExceptionTz(): void $this->process($itip, $old, $expected); } + public function testReplyNewExceptionRecurrenceIdInDifferentTz(): 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 testReplyNewExceptionRecurrenceIdInUTC(): 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