mirror of
https://github.com/usetrmnl/larapaper.git
synced 2026-08-13 14:28:54 -07:00
Fix multi-day events filtering in IcalResponseParser
This commit is contained in:
committed by
Benjamin Nussbaum
parent
44ab1131ce
commit
43b8085531
@@ -36,17 +36,21 @@ class IcalResponseParser implements ResponseParser
|
||||
$this->parser->parseString($normalizedBody);
|
||||
|
||||
$events = $this->parser->getEvents()->sorted()->getArrayCopy();
|
||||
$windowStart = now()->subDays(7);
|
||||
$windowEnd = now()->addDays(30);
|
||||
$now = now()->startOfDay();
|
||||
|
||||
$filteredEvents = array_values(array_filter($events, function (array $event) use ($windowStart, $windowEnd): bool {
|
||||
$filteredEvents = array_values(array_filter($events, function (array $event) use ($now): bool {
|
||||
$startDate = $this->asCarbon($event['DTSTART'] ?? null);
|
||||
$endDate = $this->asCarbon($event['DTEND'] ?? null);
|
||||
|
||||
if (! $startDate instanceof Carbon) {
|
||||
if (! $startDate instanceof Carbon || ! $endDate instanceof Carbon) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $startDate->between($windowStart, $windowEnd, true);
|
||||
if ($startDate->gte($now) || $endDate->gte($now)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}));
|
||||
|
||||
$normalizedEvents = array_map($this->normalizeIcalEvent(...), $filteredEvents);
|
||||
|
||||
Reference in New Issue
Block a user