Skip to content

Commit a25d57a

Browse files
fixup! fixup! feat: add iMip Request Handling
1 parent 4588c34 commit a25d57a

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

lib/private/Calendar/Manager.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -214,38 +214,38 @@ public function handleIMipRequest(
214214
string $recipient,
215215
string $calendarData,
216216
): bool {
217-
// determine if user has any calendars
217+
218218
$userCalendars = $this->getCalendarsForPrincipal($principalUri);
219219
if (empty($userCalendars)) {
220220
$this->logger->warning('iMip message could not be processed because user has on calendars');
221221
return false;
222222
}
223-
// convert calendar string data to calendar object
223+
224224
/** @var VCalendar $vObject|null */
225225
$calendarObject = Reader::read($calendarData);
226-
// determine if event has the correct method
226+
227227
if (!isset($calendarObject->METHOD) || $calendarObject->METHOD->getValue() !== 'REQUEST') {
228228
$this->logger->warning('iMip message contains an incorrect or invalid method');
229229
return false;
230230
}
231-
// determine if calendar object contains any events
231+
232232
if (!isset($calendarObject->VEVENT)) {
233233
$this->logger->warning('iMip message contains an no event');
234234
return false;
235235
}
236-
// extract event(s)
236+
237237
$eventObject = $calendarObject->VEVENT;
238-
// determine if event contains a uid
238+
239239
if (!isset($eventObject->UID)) {
240240
$this->logger->warning('iMip message event dose not contains a UID');
241241
return false;
242242
}
243-
// determine if event contains any attendees
243+
244244
if (!isset($eventObject->ATTENDEE)) {
245245
$this->logger->warning('iMip message event dose not contains any attendees');
246246
return false;
247247
}
248-
// determine if any of the attendees are the recipient
248+
249249
foreach ($eventObject->ATTENDEE as $entry) {
250250
$address = trim(str_replace('mailto:', '', $entry->getValue()));
251251
if ($address === $recipient) {
@@ -257,17 +257,17 @@ public function handleIMipRequest(
257257
$this->logger->warning('iMip message event does not contain a attendee that matches the recipient');
258258
return false;
259259
}
260-
// find event in calendar and update it
260+
261261
foreach ($userCalendars as $calendar) {
262-
// determine if calendar is deleted, shared, or read only and ignore
262+
263263
if ($calendar->isDeleted() || !$calendar->isWritable() || $calendar->isShared()) {
264264
continue;
265265
}
266-
// find event and update it
266+
267267
if (!empty($calendar->search($recipient, ['ATTENDEE'], ['uid' => $eventObject->UID->getValue()]))) {
268268
try {
269269
if ($calendar instanceof IHandleImipMessage) {
270-
$calendar->handleIMipMessage('', $calendarData); // sabre will handle the scheduling behind the scenes
270+
$calendar->handleIMipMessage('', $calendarData);
271271
}
272272
return true;
273273
} catch (CalendarException $e) {
@@ -276,7 +276,7 @@ public function handleIMipRequest(
276276
}
277277
}
278278
}
279-
// if we got this far, log the attempt and exit
279+
280280
$this->logger->warning('iMip message event could not be processed because the no corresponding event was found in any calendar');
281281
return false;
282282
}

0 commit comments

Comments
 (0)