Skip to content

Commit

Permalink
fixup! fixup! fixup! feat: add iMip Request Handling
Browse files Browse the repository at this point in the history
Signed-off-by: SebastianKrupinski <[email protected]>
  • Loading branch information
SebastianKrupinski committed Oct 20, 2024
1 parent 53365ee commit 0504968
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 62 deletions.
4 changes: 3 additions & 1 deletion apps/dav/lib/CalDAV/CachedSubscriptionImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
namespace OCA\DAV\CalDAV;

use OCP\Calendar\ICalendar;
use OCP\Calendar\ICalendarIsShared;
use OCP\Calendar\ICalendarIsWritable;
use OCP\Constants;

class CachedSubscriptionImpl implements ICalendar {
class CachedSubscriptionImpl implements ICalendar, ICalendarIsShared, ICalendarIsWritable {
private CalDavBackend $backend;
private CachedSubscription $calendar;
/** @var array<string, mixed> */
Expand Down
4 changes: 3 additions & 1 deletion apps/dav/lib/CalDAV/CalendarImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
use OCA\DAV\CalDAV\Auth\CustomPrincipalPlugin;
use OCA\DAV\CalDAV\InvitationResponse\InvitationResponseServer;
use OCP\Calendar\Exceptions\CalendarException;
use OCP\Calendar\ICalendarIsShared;
use OCP\Calendar\ICalendarIsWritable;
use OCP\Calendar\ICreateFromString;
use OCP\Calendar\IHandleImipMessage;
use OCP\Constants;
Expand All @@ -24,7 +26,7 @@
use Sabre\VObject\Reader;
use function Sabre\Uri\split as uriSplit;

class CalendarImpl implements ICreateFromString, IHandleImipMessage {
class CalendarImpl implements ICreateFromString, IHandleImipMessage, ICalendarIsWritable, ICalendarIsShared {
private CalDavBackend $backend;
private Calendar $calendar;
/** @var array<string, mixed> */
Expand Down
2 changes: 2 additions & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@
'OCP\\Calendar\\BackendTemporarilyUnavailableException' => $baseDir . '/lib/public/Calendar/BackendTemporarilyUnavailableException.php',
'OCP\\Calendar\\Exceptions\\CalendarException' => $baseDir . '/lib/public/Calendar/Exceptions/CalendarException.php',
'OCP\\Calendar\\ICalendar' => $baseDir . '/lib/public/Calendar/ICalendar.php',
'OCP\\Calendar\\ICalendarIsShared' => $baseDir . '/lib/public/Calendar/ICalendarIsShared.php',
'OCP\\Calendar\\ICalendarIsWritable' => $baseDir . '/lib/public/Calendar/ICalendarIsWritable.php',
'OCP\\Calendar\\ICalendarProvider' => $baseDir . '/lib/public/Calendar/ICalendarProvider.php',
'OCP\\Calendar\\ICalendarQuery' => $baseDir . '/lib/public/Calendar/ICalendarQuery.php',
'OCP\\Calendar\\ICreateFromString' => $baseDir . '/lib/public/Calendar/ICreateFromString.php',
Expand Down
2 changes: 2 additions & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\Calendar\\BackendTemporarilyUnavailableException' => __DIR__ . '/../../..' . '/lib/public/Calendar/BackendTemporarilyUnavailableException.php',
'OCP\\Calendar\\Exceptions\\CalendarException' => __DIR__ . '/../../..' . '/lib/public/Calendar/Exceptions/CalendarException.php',
'OCP\\Calendar\\ICalendar' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendar.php',
'OCP\\Calendar\\ICalendarIsShared' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendarIsShared.php',
'OCP\\Calendar\\ICalendarIsWritable' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendarIsWritable.php',
'OCP\\Calendar\\ICalendarProvider' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendarProvider.php',
'OCP\\Calendar\\ICalendarQuery' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendarQuery.php',
'OCP\\Calendar\\ICreateFromString' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICreateFromString.php',
Expand Down
10 changes: 8 additions & 2 deletions lib/private/Calendar/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Calendar\Exceptions\CalendarException;
use OCP\Calendar\ICalendar;
use OCP\Calendar\ICalendarIsShared;
use OCP\Calendar\ICalendarIsWritable;
use OCP\Calendar\ICalendarProvider;
use OCP\Calendar\ICalendarQuery;
use OCP\Calendar\ICreateFromString;
Expand Down Expand Up @@ -217,7 +219,7 @@ public function handleIMipRequest(

$userCalendars = $this->getCalendarsForPrincipal($principalUri);
if (empty($userCalendars)) {
$this->logger->warning('iMip message could not be processed because user has on calendars');
$this->logger->warning('iMip message could not be processed because user has no calendars');
return false;
}

Expand All @@ -230,7 +232,7 @@ public function handleIMipRequest(
}

if (!isset($calendarObject->VEVENT)) {
$this->logger->warning('iMip message contains an no event');
$this->logger->warning('iMip message contains no event');
return false;
}

Expand Down Expand Up @@ -260,6 +262,10 @@ public function handleIMipRequest(

foreach ($userCalendars as $calendar) {

if (!$calendar instanceof ICalendarIsWritable && !$calendar instanceof ICalendarIsShared) {
continue;
}

if ($calendar->isDeleted() || !$calendar->isWritable() || $calendar->isShared()) {
continue;
}
Expand Down
14 changes: 0 additions & 14 deletions lib/public/Calendar/ICalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,10 @@ public function search(string $pattern, array $searchProperties = [], array $opt
*/
public function getPermissions(): int;

/**
* Indicates whether the calendar can be modified
*
* @since 31.0.0
*/
public function isWritable(): bool;

/**
* Indicates whether the calendar is in the trash bin
*
* @since 26.0.0
*/
public function isDeleted(): bool;

/**
* Indicates whether the calendar is shared with the current user
*
* @since 31.0.0
*/
public function isShared(): bool;
}
25 changes: 25 additions & 0 deletions lib/public/Calendar/ICalendarIsShared.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCP\Calendar;

/**
* ICalendar Interface Extension
*
* @since 31.0.0
*/
interface ICalendarIsShared {

/**
* Indicates whether the calendar is shared with the current user
*
* @since 31.0.0
*/
public function isShared(): bool;

}
25 changes: 25 additions & 0 deletions lib/public/Calendar/ICalendarIsWritable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCP\Calendar;

/**
* ICalendar Interface Extension
*
* @since 31.0.0
*/
interface ICalendarIsWritable {

/**
* Indicates whether the calendar can be modified
*
* @since 31.0.0
*/
public function isWritable(): bool;

}
Loading

0 comments on commit 0504968

Please sign in to comment.