Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

send invitations for shared calendars #9609

Merged
merged 1 commit into from
Jun 1, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions apps/dav/lib/CalDAV/Schedule/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
use Sabre\DAV\Server;
use Sabre\DAV\Xml\Property\LocalHref;
use Sabre\DAVACL\IPrincipal;
use Sabre\HTTP\RequestInterface;
use Sabre\HTTP\ResponseInterface;
use Sabre\VObject\Component\VCalendar;
use Sabre\VObject\Reader;

class Plugin extends \Sabre\CalDAV\Schedule\Plugin {

Expand Down Expand Up @@ -98,4 +102,67 @@ function propFindDefaultCalendarUrl(PropFind $propFind, INode $node) {
});
}
}

/**
* This method is triggered whenever there was a calendar object gets
* created or updated.
*
* Basically just a copy of parent::calendarObjectChange, with the change
* from:
* $addresses = $this->getAddressesForPrincipal($calendarNode->getOwner());
* to:
* $addresses = $this->getAddressesForPrincipal($calendarNode->getPrincipalURI());
*
* @param RequestInterface $request HTTP request
* @param ResponseInterface $response HTTP Response
* @param VCalendar $vCal Parsed iCalendar object
* @param mixed $calendarPath Path to calendar collection
* @param mixed $modified The iCalendar object has been touched.
* @param mixed $isNew Whether this was a new item or we're updating one
* @return void
*/
function calendarObjectChange(RequestInterface $request, ResponseInterface $response, VCalendar $vCal, $calendarPath, &$modified, $isNew) {

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

$calendarNode = $this->server->tree->getNodeForPath($calendarPath);

$addresses = $this->getAddressesForPrincipal(
$calendarNode->getPrincipalURI()
);

if (!$isNew) {
$node = $this->server->tree->getNodeForPath($request->getPath());
$oldObj = Reader::read($node->get());
} else {
$oldObj = null;
}

$this->processICalendarChange($oldObj, $vCal, $addresses, [], $modified);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if new participant addresses don't have an e-mail set does this do 💥 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is properly handled by processICalendarChange.

As I said in the methods comment, this is basically just a copy of parent:: calendarObjectChange, i just replaced line 133. That's why I also didn't write tests 🙈

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough!


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

}

/**
* This method checks the 'Schedule-Reply' header
* and returns false if it's 'F', otherwise true.
*
* Copied from Sabre/DAV's Schedule plugin, because it's
* private for whatever reason
*
* @param RequestInterface $request
* @return bool
*/
private function scheduleReply(RequestInterface $request) {

$scheduleReply = $request->getHeader('Schedule-Reply');
return $scheduleReply !== 'F';

}
}