Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

358 Bugfix Broker::processMessageReply #651

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions lib/ITip/Broker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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.
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -414,15 +417,15 @@ 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;
}
}
}
if (!$attendeeFound) {
// Adding a new attendee
$attendee = $newObject->add('ATTENDEE', $itipMessage->sender, [
'PARTSTAT' => $partstat,
'PARTSTAT' => $instance['partstat'],
]);
if ($itipMessage->senderName) {
$attendee['CN'] = $itipMessage->senderName;
Expand Down
123 changes: 123 additions & 0 deletions tests/VObject/ITip/BrokerProcessReplyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Comment on lines +378 to +379
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why this comment has "This should automatically create an exception."

The source code now handles this situation.
TZID=Asia/Ho_Chi_Minh:20140725T110000 is the event recurrence of DTSTART;TZID=America/Toronto:20140724T000000 that happens the next day, 20140725.

America/Toronto is UTC-4, Asia/Ho_Chi_Minh is UTC+7. So they are 11 hours apart. 0000 in Toronto is the same time as 1100 in Ho Chi Minh City.

$itip = <<<ICS
BEGIN:VCALENDAR
VERSION:2.0
METHOD:REPLY
BEGIN:VEVENT
ATTENDEE;PARTSTAT=ACCEPTED:mailto:[email protected]
ORGANIZER:mailto:[email protected]
SEQUENCE:2
RECURRENCE-ID;TZID=Asia/Ho_Chi_Minh:20140725T110000
UID:foobar
END:VEVENT
END:VCALENDAR
ICS;

$old = <<<ICS
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
SEQUENCE:2
UID:foobar
RRULE:FREQ=DAILY
DTSTART;TZID=America/Toronto:20140724T000000
DTEND;TZID=America/Toronto:20140724T010000
ATTENDEE:mailto:[email protected]
ORGANIZER:mailto:[email protected]
END:VEVENT
END:VCALENDAR
ICS;

$expected = <<<ICS
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
SEQUENCE:2
UID:foobar
RRULE:FREQ=DAILY
DTSTART;TZID=America/Toronto:20140724T000000
DTEND;TZID=America/Toronto:20140724T010000
ATTENDEE:mailto:[email protected]
ORGANIZER:mailto:[email protected]
END:VEVENT
BEGIN:VEVENT
SEQUENCE:2
UID:foobar
DTSTART;TZID=America/Toronto:20140725T000000
DTEND;TZID=America/Toronto:20140725T010000
ATTENDEE;PARTSTAT=ACCEPTED:mailto:[email protected]
ORGANIZER:mailto:[email protected]
RECURRENCE-ID;TZID=America/Toronto:20140725T000000
END:VEVENT
END:VCALENDAR
ICS;

$this->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.
Comment on lines +441 to +442
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why this comment has "This should automatically create an exception."

Similar to my other comment above, America/Toronto is UTC-4. So 0000 in Toronto is the same as 040000Z

I don't expect any exception to happen.

$itip = <<<ICS
BEGIN:VCALENDAR
VERSION:2.0
METHOD:REPLY
BEGIN:VEVENT
ATTENDEE;PARTSTAT=ACCEPTED:mailto:[email protected]
ORGANIZER:mailto:[email protected]
SEQUENCE:2
RECURRENCE-ID:20140725T040000Z
UID:foobar
END:VEVENT
END:VCALENDAR
ICS;

$old = <<<ICS
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
SEQUENCE:2
UID:foobar
RRULE:FREQ=DAILY
DTSTART;TZID=America/Toronto:20140724T000000
DTEND;TZID=America/Toronto:20140724T010000
ATTENDEE:mailto:[email protected]
ORGANIZER:mailto:[email protected]
END:VEVENT
END:VCALENDAR
ICS;

$expected = <<<ICS
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
SEQUENCE:2
UID:foobar
RRULE:FREQ=DAILY
DTSTART;TZID=America/Toronto:20140724T000000
DTEND;TZID=America/Toronto:20140724T010000
ATTENDEE:mailto:[email protected]
ORGANIZER:mailto:[email protected]
END:VEVENT
BEGIN:VEVENT
SEQUENCE:2
UID:foobar
DTSTART;TZID=America/Toronto:20140725T000000
DTEND;TZID=America/Toronto:20140725T010000
ATTENDEE;PARTSTAT=ACCEPTED:mailto:[email protected]
ORGANIZER:mailto:[email protected]
RECURRENCE-ID;TZID=America/Toronto:20140725T000000
END:VEVENT
END:VCALENDAR
ICS;

$this->process($itip, $old, $expected);
}

public function testReplyPartyCrashCreateException(): void
{
// IN this test there's a recurring event that has an exception. The
Expand Down