Skip to content

Commit

Permalink
capture invalid calendar event
Browse files Browse the repository at this point in the history
Signed-off-by: dartcafe <[email protected]>
  • Loading branch information
dartcafe committed Jan 27, 2024
1 parent 9283979 commit 1d1cd33
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 1d1cd33

Please sign in to comment.