Skip to content

Commit 3ee7db1

Browse files
authored
Merge pull request #53288 from nextcloud/backport/53274/stable30
2 parents 166a947 + 6f566f0 commit 3ee7db1

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

apps/dav/lib/CalDAV/UpcomingEventsService.php

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,36 @@ public function getEvents(string $userId, ?string $location = null): array {
4545
$this->userManager->get($userId),
4646
);
4747

48-
return array_map(fn (array $event) => new UpcomingEvent(
49-
$event['uri'],
50-
($event['objects'][0]['RECURRENCE-ID'][0] ?? null)?->getTimeStamp(),
51-
$event['calendar-uri'],
52-
$event['objects'][0]['DTSTART'][0]?->getTimestamp(),
53-
$event['objects'][0]['SUMMARY'][0] ?? null,
54-
$event['objects'][0]['LOCATION'][0] ?? null,
55-
match ($calendarAppEnabled) {
56-
// TODO: create a named, deep route in calendar
57-
// TODO: it's a code smell to just assume this route exists, find an abstraction
58-
true => $this->urlGenerator->linkToRouteAbsolute('calendar.view.index'),
59-
false => null,
60-
},
61-
), $events);
48+
return array_map(function (array $event) use ($userId, $calendarAppEnabled) {
49+
$calendarAppUrl = null;
50+
51+
if ($calendarAppEnabled) {
52+
$arguments = [
53+
'objectId' => base64_encode($this->urlGenerator->getWebroot() . '/remote.php/dav/calendars/' . $userId . '/' . $event['calendar-uri'] . '/' . $event['uri']),
54+
];
55+
56+
if (isset($event['RECURRENCE-ID'])) {
57+
$arguments['recurrenceId'] = $event['RECURRENCE-ID'][0];
58+
}
59+
/**
60+
* TODO: create a named, deep route in calendar (it's a code smell to just assume this route exists, find an abstraction)
61+
* When changing, also adjust for:
62+
* - spreed/lib/Service/CalendarIntegrationService.php#getDashboardEvents
63+
* - spreed/lib/Service/CalendarIntegrationService.php#getMutualEvents
64+
*/
65+
$calendarAppUrl = $this->urlGenerator->linkToRouteAbsolute('calendar.view.indexdirect.edit', $arguments);
66+
}
67+
68+
return new UpcomingEvent(
69+
$event['uri'],
70+
($event['objects'][0]['RECURRENCE-ID'][0] ?? null)?->getTimeStamp(),
71+
$event['calendar-uri'],
72+
$event['objects'][0]['DTSTART'][0]?->getTimestamp(),
73+
$event['objects'][0]['SUMMARY'][0] ?? null,
74+
$event['objects'][0]['LOCATION'][0] ?? null,
75+
$calendarAppUrl,
76+
);
77+
}, $events);
6278
}
6379

6480
}

0 commit comments

Comments
 (0)