Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion apps/dav/lib/CalDAV/CalendarImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OCA\DAV\CalDAV\InvitationResponse\InvitationResponseServer;
use OCP\Calendar\Exceptions\CalendarException;
use OCP\Calendar\ICalendarIsEnabled;
use OCP\Calendar\ICalendarIsPublic;
use OCP\Calendar\ICalendarIsShared;
use OCP\Calendar\ICalendarIsWritable;
use OCP\Calendar\ICreateFromString;
Expand All @@ -27,7 +28,7 @@
use Sabre\VObject\Reader;
use function Sabre\Uri\split as uriSplit;

class CalendarImpl implements ICreateFromString, IHandleImipMessage, ICalendarIsWritable, ICalendarIsShared, ICalendarIsEnabled {
class CalendarImpl implements ICreateFromString, IHandleImipMessage, ICalendarIsWritable, ICalendarIsShared, ICalendarIsEnabled, ICalendarIsPublic {
public function __construct(
private Calendar $calendar,
/** @var array<string, mixed> */
Expand Down Expand Up @@ -165,6 +166,13 @@ public function isShared(): bool {
return $this->calendar->isShared();
}

/**
* @since 33.0.1, 32.0.7, 31.0.14.1, 30.0.17.8
*/
public function getPublicToken(): ?string {
return $this->calendar->getPublishStatus() ?: null;
}

/**
* Create a new calendar event for this calendar
* by way of an ICS string
Expand Down
16 changes: 14 additions & 2 deletions apps/dav/tests/unit/CalDAV/CalendarImplTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected function setUp(): void {
$this->backend = $this->createMock(CalDavBackend::class);
$this->calendar = $this->createMock(Calendar::class);
$this->calendarInfo = [
'id' => 'fancy_id_123',
'id' => 123,
'{DAV:}displayname' => 'user readable name 123',
'{http://apple.com/ns/ical/}calendar-color' => '#AABBCC',
'uri' => '/this/is/a/uri',
Expand Down Expand Up @@ -71,7 +71,7 @@ protected function setUp(): void {


public function testGetKey(): void {
$this->assertEquals($this->calendarImpl->getKey(), 'fancy_id_123');
$this->assertEquals($this->calendarImpl->getKey(), '123');
}

public function testGetDisplayname(): void {
Expand All @@ -82,6 +82,18 @@ public function testGetDisplayColor(): void {
$this->assertEquals($this->calendarImpl->getDisplayColor(), '#AABBCC');
}

public function testGetPublicToken(): void {
$publicToken = $this->calendar->setPublishStatus(true);

$this->assertEquals($this->calendarImpl->getPublicToken(), $publicToken);
}

public function testGetPublicTokenWithPrivateCalendar(): void {
$this->calendar->setPublishStatus(false);

$this->assertNull($this->calendarImpl->getPublicToken());
}

public function testSearch(): void {
$this->backend->expects($this->once())
->method('search')
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
'OCP\\Calendar\\ICalendar' => $baseDir . '/lib/public/Calendar/ICalendar.php',
'OCP\\Calendar\\ICalendarEventBuilder' => $baseDir . '/lib/public/Calendar/ICalendarEventBuilder.php',
'OCP\\Calendar\\ICalendarIsEnabled' => $baseDir . '/lib/public/Calendar/ICalendarIsEnabled.php',
'OCP\\Calendar\\ICalendarIsPublic' => $baseDir . '/lib/public/Calendar/ICalendarIsPublic.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',
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\Calendar\\ICalendar' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendar.php',
'OCP\\Calendar\\ICalendarEventBuilder' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendarEventBuilder.php',
'OCP\\Calendar\\ICalendarIsEnabled' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendarIsEnabled.php',
'OCP\\Calendar\\ICalendarIsPublic' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendarIsPublic.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',
Expand Down
21 changes: 21 additions & 0 deletions lib/public/Calendar/ICalendarIsPublic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

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

/**
* @since 33.0.1, 32.0.7, 31.0.14.1, 30.0.17.8
*/
interface ICalendarIsPublic {
/**
* Gets the token of a publicly shared calendar.
*
* @since 33.0.1, 32.0.7, 31.0.14.1, 30.0.17.8
*/
public function getPublicToken(): ?string;
}
Loading