diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index af5bcf036073b..04baf068bb5a4 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -190,6 +190,7 @@ '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\\Exceptions\\CalendarException' => $baseDir . '/lib/public/Calendar/Exceptions/CalendarException.php', 'OCP\\Calendar\\IAvailabilityResult' => $baseDir . '/lib/public/Calendar/IAvailabilityResult.php', 'OCP\\Calendar\\ICalendar' => $baseDir . '/lib/public/Calendar/ICalendar.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index bdc67e9b3dd95..9da39bb71dc4f 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\\Exceptions\\CalendarException' => __DIR__ . '/../../..' . '/lib/public/Calendar/Exceptions/CalendarException.php', 'OCP\\Calendar\\IAvailabilityResult' => __DIR__ . '/../../..' . '/lib/public/Calendar/IAvailabilityResult.php', 'OCP\\Calendar\\ICalendar' => __DIR__ . '/../../..' . '/lib/public/Calendar/ICalendar.php', diff --git a/lib/private/Calendar/CalendarEventBuilder.php b/lib/private/Calendar/CalendarEventBuilder.php index 9198d383ef940..1aa11c2436d4d 100644 --- a/lib/private/Calendar/CalendarEventBuilder.php +++ b/lib/private/Calendar/CalendarEventBuilder.php @@ -12,6 +12,7 @@ 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 @@ public function setLocation(string $location): 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 @@ public function toIcs(): string { '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 @@ private static function addAttendeeToVEvent(VEvent $vevent, string $name, array $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 0000000000000..5e0705457584e --- /dev/null +++ b/lib/public/Calendar/CalendarEventStatus.php @@ -0,0 +1,19 @@ +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 @@ public function testToIcs(): void { 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 @@ public function testToIcsWithoutOrganizerAndAttendees(): void { 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 @@ public function testToIcsWithoutMailtoPrefix(): void { 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');