@@ -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