diff --git a/apps/dav/lib/CalDAV/CalendarImpl.php b/apps/dav/lib/CalDAV/CalendarImpl.php index 4084dec762449..0fdb0dc34516b 100644 --- a/apps/dav/lib/CalDAV/CalendarImpl.php +++ b/apps/dav/lib/CalDAV/CalendarImpl.php @@ -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\ICreateFromString; use OCP\Calendar\IHandleImipMessage; use OCP\Constants; @@ -25,7 +26,7 @@ use Sabre\VObject\Reader; use function Sabre\Uri\split as uriSplit; -class CalendarImpl implements ICreateFromString, IHandleImipMessage, ICalendarIsEnabled { +class CalendarImpl implements ICreateFromString, IHandleImipMessage, ICalendarIsEnabled, ICalendarIsPublic { private CalDavBackend $backend; private Calendar $calendar; /** @var array */ @@ -147,6 +148,13 @@ public function isDeleted(): bool { return $this->calendar->isDeleted(); } + /** + * @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 diff --git a/apps/dav/tests/unit/CalDAV/CalendarImplTest.php b/apps/dav/tests/unit/CalDAV/CalendarImplTest.php index 87b515ca5f31a..7366355c92020 100644 --- a/apps/dav/tests/unit/CalDAV/CalendarImplTest.php +++ b/apps/dav/tests/unit/CalDAV/CalendarImplTest.php @@ -38,7 +38,7 @@ protected function setUp(): void { $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' @@ -51,7 +51,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 { @@ -62,6 +62,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') diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index f939c37bcde9d..c5a058b2389d7 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -164,6 +164,7 @@ 'OCP\\Calendar\\Exceptions\\CalendarException' => $baseDir . '/lib/public/Calendar/Exceptions/CalendarException.php', 'OCP\\Calendar\\ICalendar' => $baseDir . '/lib/public/Calendar/ICalendar.php', 'OCP\\Calendar\\ICalendarIsEnabled' => $baseDir . '/lib/public/Calendar/ICalendarIsEnabled.php', + 'OCP\\Calendar\\ICalendarIsPublic' => $baseDir . '/lib/public/Calendar/ICalendarIsPublic.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', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 2f51c414c64aa..76f917ec448f5 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -197,6 +197,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\Calendar\\Exceptions\\CalendarException' => __DIR__ . '/../../..' . '/lib/public/Calendar/Exceptions/CalendarException.php', 'OCP\\Calendar\\ICalendar' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendar.php', 'OCP\\Calendar\\ICalendarIsEnabled' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendarIsEnabled.php', + 'OCP\\Calendar\\ICalendarIsPublic' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendarIsPublic.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', diff --git a/lib/public/Calendar/ICalendarIsPublic.php b/lib/public/Calendar/ICalendarIsPublic.php new file mode 100644 index 0000000000000..1cf66de2ddcdc --- /dev/null +++ b/lib/public/Calendar/ICalendarIsPublic.php @@ -0,0 +1,21 @@ +