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