@@ -214,38 +214,38 @@ public function handleIMipRequest(
214
214
string $ recipient ,
215
215
string $ calendarData ,
216
216
): bool {
217
- // determine if user has any calendars
217
+
218
218
$ userCalendars = $ this ->getCalendarsForPrincipal ($ principalUri );
219
219
if (empty ($ userCalendars )) {
220
220
$ this ->logger ->warning ('iMip message could not be processed because user has on calendars ' );
221
221
return false ;
222
222
}
223
- // convert calendar string data to calendar object
223
+
224
224
/** @var VCalendar $vObject|null */
225
225
$ calendarObject = Reader::read ($ calendarData );
226
- // determine if event has the correct method
226
+
227
227
if (!isset ($ calendarObject ->METHOD ) || $ calendarObject ->METHOD ->getValue () !== 'REQUEST ' ) {
228
228
$ this ->logger ->warning ('iMip message contains an incorrect or invalid method ' );
229
229
return false ;
230
230
}
231
- // determine if calendar object contains any events
231
+
232
232
if (!isset ($ calendarObject ->VEVENT )) {
233
233
$ this ->logger ->warning ('iMip message contains an no event ' );
234
234
return false ;
235
235
}
236
- // extract event(s)
236
+
237
237
$ eventObject = $ calendarObject ->VEVENT ;
238
- // determine if event contains a uid
238
+
239
239
if (!isset ($ eventObject ->UID )) {
240
240
$ this ->logger ->warning ('iMip message event dose not contains a UID ' );
241
241
return false ;
242
242
}
243
- // determine if event contains any attendees
243
+
244
244
if (!isset ($ eventObject ->ATTENDEE )) {
245
245
$ this ->logger ->warning ('iMip message event dose not contains any attendees ' );
246
246
return false ;
247
247
}
248
- // determine if any of the attendees are the recipient
248
+
249
249
foreach ($ eventObject ->ATTENDEE as $ entry ) {
250
250
$ address = trim (str_replace ('mailto: ' , '' , $ entry ->getValue ()));
251
251
if ($ address === $ recipient ) {
@@ -257,17 +257,17 @@ public function handleIMipRequest(
257
257
$ this ->logger ->warning ('iMip message event does not contain a attendee that matches the recipient ' );
258
258
return false ;
259
259
}
260
- // find event in calendar and update it
260
+
261
261
foreach ($ userCalendars as $ calendar ) {
262
- // determine if calendar is deleted, shared, or read only and ignore
262
+
263
263
if ($ calendar ->isDeleted () || !$ calendar ->isWritable () || $ calendar ->isShared ()) {
264
264
continue ;
265
265
}
266
- // find event and update it
266
+
267
267
if (!empty ($ calendar ->search ($ recipient , ['ATTENDEE ' ], ['uid ' => $ eventObject ->UID ->getValue ()]))) {
268
268
try {
269
269
if ($ calendar instanceof IHandleImipMessage) {
270
- $ calendar ->handleIMipMessage ('' , $ calendarData ); // sabre will handle the scheduling behind the scenes
270
+ $ calendar ->handleIMipMessage ('' , $ calendarData );
271
271
}
272
272
return true ;
273
273
} catch (CalendarException $ e ) {
@@ -276,7 +276,7 @@ public function handleIMipRequest(
276
276
}
277
277
}
278
278
}
279
- // if we got this far, log the attempt and exit
279
+
280
280
$ this ->logger ->warning ('iMip message event could not be processed because the no corresponding event was found in any calendar ' );
281
281
return false ;
282
282
}
0 commit comments