-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45667 from nextcloud/fix/caldav/strict-default-ca…
…lendar-checks fix(caldav): stricter default calendar checks
- Loading branch information
Showing
13 changed files
with
326 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCA\DAV\CalDAV; | ||
|
||
use Sabre\DAV\Exception as DavException; | ||
|
||
class DefaultCalendarValidator { | ||
/** | ||
* Check if a given Calendar node is suitable to be used as the default calendar for scheduling. | ||
* | ||
* @throws DavException If the calendar is not suitable to be used as the default calendar | ||
*/ | ||
public function validateScheduleDefaultCalendar(Calendar $calendar): void { | ||
// Sanity checks for a calendar that should handle invitations | ||
if ($calendar->isSubscription() | ||
|| !$calendar->canWrite() | ||
|| $calendar->isShared() | ||
|| $calendar->isDeleted()) { | ||
throw new DavException('Calendar is a subscription, not writable, shared or deleted'); | ||
} | ||
|
||
// Calendar must support VEVENTs | ||
$sCCS = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set'; | ||
$calendarProperties = $calendar->getProperties([$sCCS]); | ||
if (isset($calendarProperties[$sCCS])) { | ||
$supportedComponents = $calendarProperties[$sCCS]->getValue(); | ||
} else { | ||
$supportedComponents = ['VJOURNAL', 'VTODO', 'VEVENT']; | ||
} | ||
if (!in_array('VEVENT', $supportedComponents, true)) { | ||
throw new DavException('Calendar does not support VEVENT components'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.