Skip to content

Commit

Permalink
Merge pull request #3268 from nextcloud/fix/capture-invalid-calendar-…
Browse files Browse the repository at this point in the history
…events

capture invalid calendar event
  • Loading branch information
dartcafe authored Jan 27, 2024
2 parents 9283979 + 1d1cd33 commit e4de871
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/Service/CalendarService.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
use OCP\Calendar\ICalendar;
use OCP\Calendar\IManager as CalendarManager;
use OCP\ISession;
use Psr\Log\LoggerInterface;

class CalendarService {
/** @var ICalendar[] */
Expand All @@ -52,6 +53,7 @@ public function __construct(
private Preferences $preferences,
private PreferencesService $preferencesService,
private UserMapper $userMapper,
private LoggerInterface $logger,
) {
$this->preferences = $this->preferencesService->get();
$this->currentUser = $this->userMapper->getCurrentUser();
Expand Down Expand Up @@ -130,16 +132,21 @@ public function getEvents(int $optionId): array {
$events = [];
$foundEvents = $this->searchEventsByTimeRange($timerange['from'], $timerange['to']);

if (!$foundEvents) {
return [];
}

// if (!$foundEvents) {
// return [];
// }
foreach ($foundEvents as $event) {
$calendar = $this->getCalendarFromEvent($event);
if ($calendar === null) {
continue;
}

if (!isset($event['objects'][0])) {
$this->logger->warning('Skipping invalid calendar entry', ['calendarEvent' => json_encode($event)]);
continue;
}

$calendarEvent = new CalendarEvent($event, $calendar, $timerange['from'], $timerange['to'], $timezone);

if ($calendarEvent->getOccurrences()) {
Expand Down

0 comments on commit e4de871

Please sign in to comment.