Skip to content

Commit f7d73b0

Browse files
committed
Fix various errors in iMIP logic
Signed-off-by: Anna Larch <anna@nextcloud.com>
1 parent 98c525a commit f7d73b0

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

lib/private/Calendar/Manager.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,27 @@ public function handleIMipCancel(string $principalUri, string $sender, ?string $
330330
// to the email address in the ORGANIZER.
331331
// We don't want to accept a CANCEL request from just anyone
332332
$organizer = substr($vEvent->{'ORGANIZER'}->getValue(), 7);
333-
if (strcasecmp($sender, $organizer) !== 0 && strcasecmp($replyTo, $organizer) !== 0) {
333+
$isNotOrganizer = ($replyTo !== null) ? (strcasecmp($sender, $organizer) !== 0 && strcasecmp($replyTo, $organizer) !== 0) : (strcasecmp($sender, $organizer) !== 0);
334+
if ($isNotOrganizer) {
334335
$this->logger->warning('Sender must be the ORGANIZER of this event');
335336
return false;
336337
}
337338

339+
//check if the event is in the future
340+
/** @var DateTime $eventTime */
341+
$eventTime = $vEvent->{'DTSTART'};
342+
if ($eventTime->getDateTime()->getTimeStamp() < $this->timeFactory->getTime()) { // this might cause issues with recurrences
343+
$this->logger->warning('Only events in the future are processed');
344+
return false;
345+
}
346+
347+
// Check if we have a calendar to work with
338348
$calendars = $this->getCalendarsForPrincipal($principalUri);
349+
if (empty($calendars)) {
350+
$this->logger->warning('Could not find any calendars for principal ' . $principalUri);
351+
return false;
352+
}
353+
339354
$found = null;
340355
// if the attendee has been found in at least one calendar event with the UID of the iMIP event
341356
// we process it.

0 commit comments

Comments
 (0)