From c725ecaed70caa636baa63953ba9d926b8e22dce Mon Sep 17 00:00:00 2001 From: Richard Steinmetz Date: Thu, 9 Jan 2025 10:42:22 +0100 Subject: [PATCH] fixup! feat(ocp): add calendar api to retrieve availability of attendees --- lib/private/Calendar/Manager.php | 9 ++++++++- tests/lib/Calendar/ManagerTest.php | 2 -- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/private/Calendar/Manager.php b/lib/private/Calendar/Manager.php index 8799e0f858032..5a8fc8db09248 100644 --- a/lib/private/Calendar/Manager.php +++ b/lib/private/Calendar/Manager.php @@ -33,6 +33,7 @@ use Sabre\HTTP\Response; use Sabre\VObject\Component\VCalendar; use Sabre\VObject\Component\VEvent; +use Sabre\VObject\Component\VFreeBusy; use Sabre\VObject\Property\VCard\DateTime; use Sabre\VObject\Reader; use Throwable; @@ -560,11 +561,17 @@ public function checkAvailability( $mailtoLen, ); + $vfreebusy = $freeBusyResponseData->VFREEBUSY; + if (!($vfreebusy instanceof VFreeBusy)) { + continue; + } + // TODO: actually check values of FREEBUSY properties to find a free slot $isAvailable = true; - $freeBusyProps = $freeBusyResponseData->VFREEBUSY->FREEBUSY; + $freeBusyProps = $vfreebusy->FREEBUSY; if ($freeBusyProps !== null) { foreach ($freeBusyProps as $prop) { + // BUSY is the default, in case FBTYPE is not present if (isset($prop['FBTYPE']) && $prop['FBTYPE'] === 'FREE') { continue; } diff --git a/tests/lib/Calendar/ManagerTest.php b/tests/lib/Calendar/ManagerTest.php index 3fa63a9a70d57..4490a26c54a5b 100644 --- a/tests/lib/Calendar/ManagerTest.php +++ b/tests/lib/Calendar/ManagerTest.php @@ -6,7 +6,6 @@ namespace Test\Calendar; -use AdvancedJsonRpc\Request; use DateTimeImmutable; use OC\AppFramework\Bootstrap\Coordinator; use OC\Calendar\AvailabilityResult; @@ -28,7 +27,6 @@ use Psr\Log\LoggerInterface; use Sabre\DAV\Exception\Forbidden; use Sabre\HTTP\RequestInterface; -use Sabre\HTTP\Response; use Sabre\HTTP\ResponseInterface; use Sabre\VObject\Component\VCalendar; use Sabre\VObject\Document;