Skip to content

Commit

Permalink
Add comments about use of getTimestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed May 9, 2024
1 parent 620ee98 commit bee4fa7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/ITip/Broker.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@ protected function processMessageReply(Message $itipMessage, ?VCalendar $existin

// Finding all the instances the attendee replied to.
foreach ($itipMessage->message->VEVENT as $vevent) {
// Use the Unix timestamp returned by getTimestamp as a unique identifier for the recurrence.
// The Unix timestamp will be the same for an event, even if the reply from the attendee
// used a different format/timezone to express the event date-time.
$recurId = isset($vevent->{'RECURRENCE-ID'}) ? $vevent->{'RECURRENCE-ID'}->getDateTime()->getTimestamp() : 'master';
$attendee = $vevent->ATTENDEE;
$instances[$recurId] = $attendee['PARTSTAT']->getValue();
Expand All @@ -346,6 +349,7 @@ protected function processMessageReply(Message $itipMessage, ?VCalendar $existin
// all the instances where we have a reply for.
$masterObject = null;
foreach ($existingObject->VEVENT as $vevent) {
// Use the Unix timestamp returned by getTimestamp as a unique identifier for the recurrence.
$recurId = isset($vevent->{'RECURRENCE-ID'}) ? $vevent->{'RECURRENCE-ID'}->getDateTime()->getTimestamp() : 'master';
if ('master' === $recurId) {
$masterObject = $vevent;
Expand Down Expand Up @@ -393,6 +397,9 @@ protected function processMessageReply(Message $itipMessage, ?VCalendar $existin
$newObject = $recurrenceIterator->getEventObject();
$recurrenceIterator->next();

// Compare the Unix timestamp returned by getTimestamp with the previously calculated timestamp.
// If they are the same, then this is a matching recurrence, even though its date-time may have
// been expressed in a different format/timezone.
if (isset($newObject->{'RECURRENCE-ID'}) && $newObject->{'RECURRENCE-ID'}->getDateTime()->getTimestamp() === $recurId) {
$found = true;
}
Expand Down

0 comments on commit bee4fa7

Please sign in to comment.