diff options
author | SebastianKrupinski <krupinskis05@gmail.com> | 2025-03-14 23:19:16 -0400 |
---|---|---|
committer | SebastianKrupinski <krupinskis05@gmail.com> | 2025-03-28 03:48:48 -0400 |
commit | 2de6d6b908c27765cfe20dc91f2076804f0859bd (patch) | |
tree | 55fa153019f53bca1399f23e3efd3a5230d9ff88 | |
parent | d40cebb1c70f864af78517d747c723d3b5ec5ef9 (diff) | |
download | nextcloud-server-fix/noid-add-status-and-set-attendee-status.tar.gz nextcloud-server-fix/noid-add-status-and-set-attendee-status.zip |
fix: add event status and participant statusfix/noid-add-status-and-set-attendee-status
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
-rw-r--r-- | lib/composer/composer/autoload_classmap.php | 1 | ||||
-rw-r--r-- | lib/composer/composer/autoload_static.php | 1 | ||||
-rw-r--r-- | lib/private/Calendar/CalendarEventBuilder.php | 15 | ||||
-rw-r--r-- | lib/public/Calendar/CalendarEventStatus.php | 19 | ||||
-rw-r--r-- | lib/public/Calendar/ICalendarEventBuilder.php | 7 | ||||
-rw-r--r-- | openapi.json | 4 | ||||
-rw-r--r-- | tests/data/ics/event-builder-complete.ics | 1 | ||||
-rw-r--r-- | tests/data/ics/event-builder-without-attendees.ics | 1 | ||||
-rw-r--r-- | tests/lib/Calendar/CalendarEventBuilderTest.php | 5 |
9 files changed, 52 insertions, 2 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index abeaf0d513a..2d0b62d749f 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -190,6 +190,7 @@ return array( 'OCP\\Broadcast\\Events\\IBroadcastEvent' => $baseDir . '/lib/public/Broadcast/Events/IBroadcastEvent.php', 'OCP\\Cache\\CappedMemoryCache' => $baseDir . '/lib/public/Cache/CappedMemoryCache.php', 'OCP\\Calendar\\BackendTemporarilyUnavailableException' => $baseDir . '/lib/public/Calendar/BackendTemporarilyUnavailableException.php', + 'OCP\\Calendar\\CalendarEventStatus' => $baseDir . '/lib/public/Calendar/CalendarEventStatus.php', 'OCP\\Calendar\\Events\\AbstractCalendarObjectEvent' => $baseDir . '/lib/public/Calendar/Events/AbstractCalendarObjectEvent.php', 'OCP\\Calendar\\Events\\CalendarObjectCreatedEvent' => $baseDir . '/lib/public/Calendar/Events/CalendarObjectCreatedEvent.php', 'OCP\\Calendar\\Events\\CalendarObjectDeletedEvent' => $baseDir . '/lib/public/Calendar/Events/CalendarObjectDeletedEvent.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 956fa820ac5..64210bd5843 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -239,6 +239,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\Broadcast\\Events\\IBroadcastEvent' => __DIR__ . '/../../..' . '/lib/public/Broadcast/Events/IBroadcastEvent.php', 'OCP\\Cache\\CappedMemoryCache' => __DIR__ . '/../../..' . '/lib/public/Cache/CappedMemoryCache.php', 'OCP\\Calendar\\BackendTemporarilyUnavailableException' => __DIR__ . '/../../..' . '/lib/public/Calendar/BackendTemporarilyUnavailableException.php', + 'OCP\\Calendar\\CalendarEventStatus' => __DIR__ . '/../../..' . '/lib/public/Calendar/CalendarEventStatus.php', 'OCP\\Calendar\\Events\\AbstractCalendarObjectEvent' => __DIR__ . '/../../..' . '/lib/public/Calendar/Events/AbstractCalendarObjectEvent.php', 'OCP\\Calendar\\Events\\CalendarObjectCreatedEvent' => __DIR__ . '/../../..' . '/lib/public/Calendar/Events/CalendarObjectCreatedEvent.php', 'OCP\\Calendar\\Events\\CalendarObjectDeletedEvent' => __DIR__ . '/../../..' . '/lib/public/Calendar/Events/CalendarObjectDeletedEvent.php', diff --git a/lib/private/Calendar/CalendarEventBuilder.php b/lib/private/Calendar/CalendarEventBuilder.php index 9198d383ef9..1aa11c2436d 100644 --- a/lib/private/Calendar/CalendarEventBuilder.php +++ b/lib/private/Calendar/CalendarEventBuilder.php @@ -12,6 +12,7 @@ namespace OC\Calendar; use DateTimeInterface; use InvalidArgumentException; use OCP\AppFramework\Utility\ITimeFactory; +use OCP\Calendar\CalendarEventStatus; use OCP\Calendar\ICalendarEventBuilder; use OCP\Calendar\ICreateFromString; use Sabre\VObject\Component\VCalendar; @@ -23,6 +24,7 @@ class CalendarEventBuilder implements ICalendarEventBuilder { private ?string $summary = null; private ?string $description = null; private ?string $location = null; + private ?CalendarEventStatus $status = null; private ?array $organizer = null; private array $attendees = []; @@ -57,6 +59,11 @@ class CalendarEventBuilder implements ICalendarEventBuilder { return $this; } + public function setStatus(CalendarEventStatus $status): static { + $this->status = $status; + return $this; + } + public function setOrganizer(string $email, ?string $commonName = null): ICalendarEventBuilder { $this->organizer = [$email, $commonName]; return $this; @@ -91,6 +98,7 @@ class CalendarEventBuilder implements ICalendarEventBuilder { 'SUMMARY' => $this->summary, 'DTSTART' => $this->startDate, 'DTEND' => $this->endDate, + 'STATUS' => $this->status->value, ]; if ($this->description !== null) { $props['DESCRIPTION'] = $this->description; @@ -126,6 +134,13 @@ class CalendarEventBuilder implements ICalendarEventBuilder { $params = []; if ($cn !== null) { $params['CN'] = $cn; + if ($name === 'ORGANIZER') { + $params['ROLE'] = 'CHAIR'; + $params['PARTSTAT'] = 'ACCEPTED'; + } else { + $params['ROLE'] = 'REQ-PARTICIPANT'; + $params['PARTSTAT'] = 'NEEDS-ACTION'; + } } $vevent->add($name, $email, $params); } diff --git a/lib/public/Calendar/CalendarEventStatus.php b/lib/public/Calendar/CalendarEventStatus.php new file mode 100644 index 00000000000..5e070545758 --- /dev/null +++ b/lib/public/Calendar/CalendarEventStatus.php @@ -0,0 +1,19 @@ +<?php + +declare(strict_types=1); +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Calendar; + +/** + * The status of a calendar event. + * + * @since 32.0.0 + */ +enum CalendarEventStatus: string { + case TENTATIVE = 'TENTATIVE'; + case CONFIRMED = 'CONFIRMED'; + case CANCELLED = 'CANCELLED'; +}; diff --git a/lib/public/Calendar/ICalendarEventBuilder.php b/lib/public/Calendar/ICalendarEventBuilder.php index 8afc817a61e..c99dc60cc8c 100644 --- a/lib/public/Calendar/ICalendarEventBuilder.php +++ b/lib/public/Calendar/ICalendarEventBuilder.php @@ -66,6 +66,13 @@ interface ICalendarEventBuilder { public function setLocation(string $location): self; /** + * Set the event status. + * + * @since 32.0.0 + */ + public function setStatus(CalendarEventStatus $status): static; + + /** * Set the event organizer. * This property is required if attendees are added! * diff --git a/openapi.json b/openapi.json index fffdec3ad35..ce27ac48031 100644 --- a/openapi.json +++ b/openapi.json @@ -30055,7 +30055,7 @@ "nullable": true, "enum": [ "none", - "headers" + "header" ], "description": "Authentication method to use" }, @@ -30338,7 +30338,7 @@ "nullable": true, "enum": [ "none", - "headers" + "header" ], "description": "Authentication method to use" }, diff --git a/tests/data/ics/event-builder-complete.ics b/tests/data/ics/event-builder-complete.ics index d96a3137356..65fe8e6cf13 100644 --- a/tests/data/ics/event-builder-complete.ics +++ b/tests/data/ics/event-builder-complete.ics @@ -8,6 +8,7 @@ DTSTAMP:20250105T000000Z SUMMARY:My event
DTSTART:20250105T170958Z
DTEND:20250105T171958Z
+STATUS:CONFIRMED
DESCRIPTION:Foo bar baz
ORGANIZER:mailto:organizer@domain.tld
ATTENDEE:mailto:attendee1@domain.tld
diff --git a/tests/data/ics/event-builder-without-attendees.ics b/tests/data/ics/event-builder-without-attendees.ics index 95c4c44fa1f..fad48caa3a9 100644 --- a/tests/data/ics/event-builder-without-attendees.ics +++ b/tests/data/ics/event-builder-without-attendees.ics @@ -8,6 +8,7 @@ DTSTAMP:20250105T000000Z SUMMARY:My event
DTSTART:20250105T170958Z
DTEND:20250105T171958Z
+STATUS:CONFIRMED
DESCRIPTION:Foo bar baz
END:VEVENT
END:VCALENDAR
diff --git a/tests/lib/Calendar/CalendarEventBuilderTest.php b/tests/lib/Calendar/CalendarEventBuilderTest.php index 48684d56093..b01c209cd31 100644 --- a/tests/lib/Calendar/CalendarEventBuilderTest.php +++ b/tests/lib/Calendar/CalendarEventBuilderTest.php @@ -13,6 +13,7 @@ use DateTimeImmutable; use InvalidArgumentException; use OC\Calendar\CalendarEventBuilder; use OCP\AppFramework\Utility\ITimeFactory; +use OCP\Calendar\CalendarEventStatus; use OCP\Calendar\ICreateFromString; use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; @@ -37,6 +38,7 @@ class CalendarEventBuilderTest extends TestCase { public function testToIcs(): void { $this->calendarEventBuilder->setStartDate(new DateTimeImmutable('2025-01-05T17:09:58Z')); $this->calendarEventBuilder->setEndDate(new DateTimeImmutable('2025-01-05T17:19:58Z')); + $this->calendarEventBuilder->setStatus(CalendarEventStatus::CONFIRMED); $this->calendarEventBuilder->setSummary('My event'); $this->calendarEventBuilder->setDescription('Foo bar baz'); $this->calendarEventBuilder->setOrganizer('mailto:organizer@domain.tld'); @@ -51,6 +53,7 @@ class CalendarEventBuilderTest extends TestCase { public function testToIcsWithoutOrganizerAndAttendees(): void { $this->calendarEventBuilder->setStartDate(new DateTimeImmutable('2025-01-05T17:09:58Z')); $this->calendarEventBuilder->setEndDate(new DateTimeImmutable('2025-01-05T17:19:58Z')); + $this->calendarEventBuilder->setStatus(CalendarEventStatus::CONFIRMED); $this->calendarEventBuilder->setSummary('My event'); $this->calendarEventBuilder->setDescription('Foo bar baz'); @@ -62,6 +65,7 @@ class CalendarEventBuilderTest extends TestCase { public function testToIcsWithoutMailtoPrefix(): void { $this->calendarEventBuilder->setStartDate(new DateTimeImmutable('2025-01-05T17:09:58Z')); $this->calendarEventBuilder->setEndDate(new DateTimeImmutable('2025-01-05T17:19:58Z')); + $this->calendarEventBuilder->setStatus(CalendarEventStatus::CONFIRMED); $this->calendarEventBuilder->setSummary('My event'); $this->calendarEventBuilder->setDescription('Foo bar baz'); $this->calendarEventBuilder->setOrganizer('organizer@domain.tld'); @@ -76,6 +80,7 @@ class CalendarEventBuilderTest extends TestCase { public function testCreateInCalendar(): void { $this->calendarEventBuilder->setStartDate(new DateTimeImmutable('2025-01-05T17:09:58Z')); $this->calendarEventBuilder->setEndDate(new DateTimeImmutable('2025-01-05T17:19:58Z')); + $this->calendarEventBuilder->setStatus(CalendarEventStatus::CONFIRMED); $this->calendarEventBuilder->setSummary('My event'); $this->calendarEventBuilder->setDescription('Foo bar baz'); $this->calendarEventBuilder->setOrganizer('organizer@domain.tld'); |