Skip to content

Commit

Permalink
Disable sharing calendars via link when sharik via link is disabled
Browse files Browse the repository at this point in the history
This mod disallows sharing calendars via link when `shareapi_allow_links`
is disabled.

Related: nextcloud/calendar#525
Related: nextcloud/calendar#4399
Author-Change-Id: IB#1126264
Signed-off-by: Pawel Boguslawski <pawel.boguslawski@ib.pl>
  • Loading branch information
pboguslawski authored and tcitworld committed Oct 28, 2022
1 parent 12815c1 commit 588574d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions apps/dav/lib/CalDAV/CalDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* @copyright Copyright (c) 2016, ownCloud, Inc.
* @copyright Copyright (c) 2018 Georg Ehrke
* @copyright Copyright (c) 2020, leith abdulla (<online-nextcloud@eleith.com>)
* @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/
*
* @author Chih-Hsuan Yen <yan12125@gmail.com>
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
Expand Down Expand Up @@ -516,6 +517,10 @@ private function getUserDisplayName($uid) {
* @return array
*/
public function getPublicCalendars() {
// Sharing via link must be enabled.
if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'no' ) {
return array_values([]);
}
$fields = array_column($this->propertyMap, 0);
$fields[] = 'a.id';
$fields[] = 'a.uri';
Expand Down Expand Up @@ -574,6 +579,10 @@ public function getPublicCalendars() {
* @throws NotFound
*/
public function getPublicCalendar($uri) {
// Sharing via link must be enabled.
if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'no' ) {
throw new NotFound('Node with name \'' . $uri . '\' could not be found');
}
$fields = array_column($this->propertyMap, 0);
$fields[] = 'a.id';
$fields[] = 'a.uri';
Expand Down
6 changes: 6 additions & 0 deletions apps/dav/lib/CalDAV/Publishing/PublishPlugin.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/**
* @copyright Copyright (c) 2016 Thomas Citharel <tcit@tcit.fr>
* @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Georg Ehrke <oc.list@georgehrke.com>
Expand Down Expand Up @@ -205,6 +206,11 @@ public function httpPost(RequestInterface $request, ResponseInterface $response)
}
}

// Sharing via link must be enabled.
if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'no') {
return;
}

$node->setPublishStatus(true);

// iCloud sends back the 202, so we will too.
Expand Down

0 comments on commit 588574d

Please sign in to comment.