From 8766ea1b4928c3a84fd90aca3a0667d1c833c532 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sun, 29 Mar 2026 11:12:08 +0200 Subject: [PATCH] fix(caldav): handle non-vevents in CalDavEventListener For instance if vobject contains vtodos or vjournals Signed-off-by: Thomas Citharel --- lib/Listener/CalDavEventListener.php | 9 +++++- .../php/Listener/CalDavEventListenerTest.php | 31 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/lib/Listener/CalDavEventListener.php b/lib/Listener/CalDavEventListener.php index fa47a9b7c2d..5a2326f7bdb 100644 --- a/lib/Listener/CalDavEventListener.php +++ b/lib/Listener/CalDavEventListener.php @@ -70,7 +70,7 @@ public function handle(Event $event): void { } if (!str_contains($calData, 'LOCATION:')) { - $this->logger->debug('No location for the even, skipping for calendar event integration'); + $this->logger->debug('No location for the event, skipping for calendar event integration'); return; } @@ -82,6 +82,13 @@ public function handle(Event $event): void { } $vevent = $vobject->VEVENT; + + // Calendar objects can also be VTODO or VJOURNAL for instance + if ($vevent === null) { + $this->logger->debug('Calendar object is not an event, skipping for calendar event integration'); + return; + } + // Check if the location is set and if the location string contains a call url $location = $vevent->LOCATION?->getValue(); if ($location === null || !str_contains($location, '/call/')) { diff --git a/tests/php/Listener/CalDavEventListenerTest.php b/tests/php/Listener/CalDavEventListenerTest.php index 5f106a8b194..4a876d4ac4e 100644 --- a/tests/php/Listener/CalDavEventListenerTest.php +++ b/tests/php/Listener/CalDavEventListenerTest.php @@ -162,6 +162,37 @@ public function testIsCalendarEventSystemCalendar(): void { $this->listener->handle($event); } + public function testIsCalendarEventNoEventInVObject(): void { + $calData = << $this->userUri], [], ['calendardata' => $calData]); + + $this->logger->expects(self::once()) + ->method('debug') + ->with('Calendar object is not an event, skipping for calendar event integration'); + + $this->listener->handle($event); + } + public function testIsCalendarEventNoData(): void { $event = new CalendarObjectCreatedEvent(1, ['principaluri' => $this->userUri], [], []);