Skip to content

Commit 0504968

Browse files
fixup! fixup! fixup! feat: add iMip Request Handling
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
1 parent 53365ee commit 0504968

File tree

9 files changed

+108
-62
lines changed

9 files changed

+108
-62
lines changed

apps/dav/lib/CalDAV/CachedSubscriptionImpl.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
namespace OCA\DAV\CalDAV;
1010

1111
use OCP\Calendar\ICalendar;
12+
use OCP\Calendar\ICalendarIsShared;
13+
use OCP\Calendar\ICalendarIsWritable;
1214
use OCP\Constants;
1315

14-
class CachedSubscriptionImpl implements ICalendar {
16+
class CachedSubscriptionImpl implements ICalendar, ICalendarIsShared, ICalendarIsWritable {
1517
private CalDavBackend $backend;
1618
private CachedSubscription $calendar;
1719
/** @var array<string, mixed> */

apps/dav/lib/CalDAV/CalendarImpl.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
use OCA\DAV\CalDAV\Auth\CustomPrincipalPlugin;
1212
use OCA\DAV\CalDAV\InvitationResponse\InvitationResponseServer;
1313
use OCP\Calendar\Exceptions\CalendarException;
14+
use OCP\Calendar\ICalendarIsShared;
15+
use OCP\Calendar\ICalendarIsWritable;
1416
use OCP\Calendar\ICreateFromString;
1517
use OCP\Calendar\IHandleImipMessage;
1618
use OCP\Constants;
@@ -24,7 +26,7 @@
2426
use Sabre\VObject\Reader;
2527
use function Sabre\Uri\split as uriSplit;
2628

27-
class CalendarImpl implements ICreateFromString, IHandleImipMessage {
29+
class CalendarImpl implements ICreateFromString, IHandleImipMessage, ICalendarIsWritable, ICalendarIsShared {
2830
private CalDavBackend $backend;
2931
private Calendar $calendar;
3032
/** @var array<string, mixed> */

lib/composer/composer/autoload_classmap.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@
163163
'OCP\\Calendar\\BackendTemporarilyUnavailableException' => $baseDir . '/lib/public/Calendar/BackendTemporarilyUnavailableException.php',
164164
'OCP\\Calendar\\Exceptions\\CalendarException' => $baseDir . '/lib/public/Calendar/Exceptions/CalendarException.php',
165165
'OCP\\Calendar\\ICalendar' => $baseDir . '/lib/public/Calendar/ICalendar.php',
166+
'OCP\\Calendar\\ICalendarIsShared' => $baseDir . '/lib/public/Calendar/ICalendarIsShared.php',
167+
'OCP\\Calendar\\ICalendarIsWritable' => $baseDir . '/lib/public/Calendar/ICalendarIsWritable.php',
166168
'OCP\\Calendar\\ICalendarProvider' => $baseDir . '/lib/public/Calendar/ICalendarProvider.php',
167169
'OCP\\Calendar\\ICalendarQuery' => $baseDir . '/lib/public/Calendar/ICalendarQuery.php',
168170
'OCP\\Calendar\\ICreateFromString' => $baseDir . '/lib/public/Calendar/ICreateFromString.php',

lib/composer/composer/autoload_static.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
196196
'OCP\\Calendar\\BackendTemporarilyUnavailableException' => __DIR__ . '/../../..' . '/lib/public/Calendar/BackendTemporarilyUnavailableException.php',
197197
'OCP\\Calendar\\Exceptions\\CalendarException' => __DIR__ . '/../../..' . '/lib/public/Calendar/Exceptions/CalendarException.php',
198198
'OCP\\Calendar\\ICalendar' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendar.php',
199+
'OCP\\Calendar\\ICalendarIsShared' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendarIsShared.php',
200+
'OCP\\Calendar\\ICalendarIsWritable' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendarIsWritable.php',
199201
'OCP\\Calendar\\ICalendarProvider' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendarProvider.php',
200202
'OCP\\Calendar\\ICalendarQuery' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendarQuery.php',
201203
'OCP\\Calendar\\ICreateFromString' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICreateFromString.php',

lib/private/Calendar/Manager.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use OCP\AppFramework\Utility\ITimeFactory;
1313
use OCP\Calendar\Exceptions\CalendarException;
1414
use OCP\Calendar\ICalendar;
15+
use OCP\Calendar\ICalendarIsShared;
16+
use OCP\Calendar\ICalendarIsWritable;
1517
use OCP\Calendar\ICalendarProvider;
1618
use OCP\Calendar\ICalendarQuery;
1719
use OCP\Calendar\ICreateFromString;
@@ -217,7 +219,7 @@ public function handleIMipRequest(
217219

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

@@ -230,7 +232,7 @@ public function handleIMipRequest(
230232
}
231233

232234
if (!isset($calendarObject->VEVENT)) {
233-
$this->logger->warning('iMip message contains an no event');
235+
$this->logger->warning('iMip message contains no event');
234236
return false;
235237
}
236238

@@ -260,6 +262,10 @@ public function handleIMipRequest(
260262

261263
foreach ($userCalendars as $calendar) {
262264

265+
if (!$calendar instanceof ICalendarIsWritable && !$calendar instanceof ICalendarIsShared) {
266+
continue;
267+
}
268+
263269
if ($calendar->isDeleted() || !$calendar->isWritable() || $calendar->isShared()) {
264270
continue;
265271
}

lib/public/Calendar/ICalendar.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,24 +58,10 @@ public function search(string $pattern, array $searchProperties = [], array $opt
5858
*/
5959
public function getPermissions(): int;
6060

61-
/**
62-
* Indicates whether the calendar can be modified
63-
*
64-
* @since 31.0.0
65-
*/
66-
public function isWritable(): bool;
67-
6861
/**
6962
* Indicates whether the calendar is in the trash bin
7063
*
7164
* @since 26.0.0
7265
*/
7366
public function isDeleted(): bool;
74-
75-
/**
76-
* Indicates whether the calendar is shared with the current user
77-
*
78-
* @since 31.0.0
79-
*/
80-
public function isShared(): bool;
8167
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
namespace OCP\Calendar;
10+
11+
/**
12+
* ICalendar Interface Extension
13+
*
14+
* @since 31.0.0
15+
*/
16+
interface ICalendarIsShared {
17+
18+
/**
19+
* Indicates whether the calendar is shared with the current user
20+
*
21+
* @since 31.0.0
22+
*/
23+
public function isShared(): bool;
24+
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
namespace OCP\Calendar;
10+
11+
/**
12+
* ICalendar Interface Extension
13+
*
14+
* @since 31.0.0
15+
*/
16+
interface ICalendarIsWritable {
17+
18+
/**
19+
* Indicates whether the calendar can be modified
20+
*
21+
* @since 31.0.0
22+
*/
23+
public function isWritable(): bool;
24+
25+
}

0 commit comments

Comments
 (0)