Skip to content

Commit

Permalink
Merge pull request #45054 from nextcloud/fix/issue-26668
Browse files Browse the repository at this point in the history
fix(caldav): Add sharee to address list when calendar is shared
  • Loading branch information
SebastianKrupinski authored Aug 6, 2024
2 parents 69f01b1 + 0df3036 commit 1e2bf36
Show file tree
Hide file tree
Showing 2 changed files with 408 additions and 32 deletions.
39 changes: 38 additions & 1 deletion apps/dav/lib/CalDAV/Schedule/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,42 @@ public function calendarObjectChange(RequestInterface $request, ResponseInterfac
}

try {
parent::calendarObjectChange($request, $response, $vCal, $calendarPath, $modified, $isNew);

if (!$this->scheduleReply($this->server->httpRequest)) {
return;
}

/** @var \OCA\DAV\CalDAV\Calendar $calendarNode */
$calendarNode = $this->server->tree->getNodeForPath($calendarPath);
// extract addresses for owner
$addresses = $this->getAddressesForPrincipal($calendarNode->getOwner());
// determain if request is from a sharee
if ($calendarNode->isShared()) {
// extract addresses for sharee and add to address collection
$addresses = array_merge(
$addresses,
$this->getAddressesForPrincipal($calendarNode->getPrincipalURI())
);
}
// determine if we are updating a calendar event
if (!$isNew) {
// retrieve current calendar event node
/** @var \OCA\DAV\CalDAV\CalendarObject $currentNode */
$currentNode = $this->server->tree->getNodeForPath($request->getPath());
// convert calendar event string data to VCalendar object
/** @var \Sabre\VObject\Component\VCalendar $currentObject */
$currentObject = Reader::read($currentNode->get());
} else {
$currentObject = null;
}
// process request
$this->processICalendarChange($currentObject, $vCal, $addresses, [], $modified);

if ($currentObject) {
// Destroy circular references so PHP will GC the object.
$currentObject->destroy();
}

} catch (SameOrganizerForAllComponentsException $e) {
$this->handleSameOrganizerException($e, $vCal, $calendarPath);
}
Expand Down Expand Up @@ -526,7 +561,9 @@ private function isAvailableAtTime(string $email, \DateTimeInterface $start, \Da
$calendarTimeZone = new DateTimeZone('UTC');

$homePath = $result[0][200]['{' . self::NS_CALDAV . '}calendar-home-set']->getHref();
/** @var \OCA\DAV\CalDAV\Calendar $node */
foreach ($this->server->tree->getNodeForPath($homePath)->getChildren() as $node) {

if (!$node instanceof ICalendar) {
continue;
}
Expand Down
Loading

0 comments on commit 1e2bf36

Please sign in to comment.