99namespace OCA \DAV \CalDAV \Schedule ;
1010
1111use OC \URLGenerator ;
12+ use OCA \DAV \CalDAV \CaldavBackend ;
1213use OCA \DAV \CalDAV \EventReader ;
1314use OCP \AppFramework \Utility \ITimeFactory ;
1415use OCP \IConfig ;
2324use Sabre \VObject \ITip \Message ;
2425use Sabre \VObject \Parameter ;
2526use Sabre \VObject \Property ;
27+ use Sabre \VObject \Reader ;
2628use Sabre \VObject \Recur \EventIterator ;
2729
2830class IMipService {
@@ -44,6 +46,7 @@ public function __construct(
4446 private ISecureRandom $ random ,
4547 private L10NFactory $ l10nFactory ,
4648 private ITimeFactory $ timeFactory ,
49+ private CaldavBackend $ caldavBackend ,
4750 ) {
4851 $ language = $ this ->l10nFactory ->findGenericLanguage ();
4952 $ locale = $ this ->l10nFactory ->findLocale ($ language );
@@ -159,7 +162,35 @@ public function buildBodyData(VEvent $vEvent, ?VEvent $oldVEvent): array {
159162 if ($ eventReaderCurrent ->recurs ()) {
160163 $ data ['meeting_occurring ' ] = $ this ->generateOccurringString ($ eventReaderCurrent );
161164 }
162-
165+ return $ data ;
166+ }
167+
168+ /**
169+ * @param VEvent $vEvent
170+ * @return array
171+ */
172+ public function buildReplyBodyData (VEvent $ vEvent ): array {
173+ // construct event reader
174+ $ eventReader = new EventReader ($ vEvent );
175+ $ defaultVal = '' ;
176+ $ data = [];
177+ $ data ['meeting_when ' ] = $ this ->generateWhenString ($ eventReader );
178+
179+ foreach (self ::STRING_DIFF as $ key => $ property ) {
180+ $ data [$ key ] = self ::readPropertyWithDefault ($ vEvent , $ property , $ defaultVal );
181+ }
182+
183+ if (($ locationHtml = $ this ->linkify ($ data ['meeting_location ' ])) !== null ) {
184+ $ data ['meeting_location_html ' ] = $ locationHtml ;
185+ }
186+
187+ $ data ['meeting_url_html ' ] = $ data ['meeting_url ' ] ? sprintf ('<a href="%1$s">%1$s</a> ' , $ data ['meeting_url ' ]) : '' ;
188+
189+ // generate occurring next string
190+ if ($ eventReader ->recurs ()) {
191+ $ data ['meeting_occurring ' ] = $ this ->generateOccurringString ($ eventReader );
192+ }
193+
163194 return $ data ;
164195 }
165196
@@ -1142,6 +1173,11 @@ public function getReplyingAttendee(Message $iTipMessage): ?Property {
11421173 return null ;
11431174 }
11441175
1176+ public function getOrganizerVEvent (string $ uid , string $ organizerUri ): VEvent {
1177+ $ organizerEvent = $ this ->caldavBackend ->findEventDataByUri ($ uid , $ organizerUri );
1178+ return Reader::read ($ organizerEvent ['calendardata ' ])->VEVENT ;
1179+ }
1180+
11451181 public function isRoomOrResource (Property $ attendee ): bool {
11461182 $ cuType = $ attendee ->offsetGet ('CUTYPE ' );
11471183 if (!$ cuType instanceof Parameter) {
0 commit comments