mirror of
https://github.com/nextcloud/server.git
synced 2026-06-11 09:42:09 -04:00
feat(CalDAV): Add function to get the token of a publicly shared calendar
Signed-off-by: David Dreschner <david.dreschner@nextcloud.com>
This commit is contained in:
parent
224d240fdf
commit
295df7ff66
5 changed files with 46 additions and 3 deletions
|
|
@ -12,6 +12,7 @@ use OCA\DAV\CalDAV\Auth\CustomPrincipalPlugin;
|
|||
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;
|
||||
|
|
@ -27,7 +28,7 @@ use Sabre\VObject\Property;
|
|||
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> */
|
||||
|
|
@ -165,6 +166,13 @@ class CalendarImpl implements ICreateFromString, IHandleImipMessage, ICalendarIs
|
|||
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
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class CalendarImplTest extends \Test\TestCase {
|
|||
$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',
|
||||
|
|
@ -71,7 +71,7 @@ class CalendarImplTest extends \Test\TestCase {
|
|||
|
||||
|
||||
public function testGetKey(): void {
|
||||
$this->assertEquals($this->calendarImpl->getKey(), 'fancy_id_123');
|
||||
$this->assertEquals($this->calendarImpl->getKey(), '123');
|
||||
}
|
||||
|
||||
public function testGetDisplayname(): void {
|
||||
|
|
@ -82,6 +82,18 @@ class CalendarImplTest extends \Test\TestCase {
|
|||
$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')
|
||||
|
|
|
|||
|
|
@ -203,6 +203,7 @@ return array(
|
|||
'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',
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
21
lib/public/Calendar/ICalendarIsPublic.php
Normal file
21
lib/public/Calendar/ICalendarIsPublic.php
Normal file
|
|
@ -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…
Reference in a new issue