fix: add event status and participant status

Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
pull/51501/head
SebastianKrupinski 3 weeks ago
parent d40cebb1c7
commit 2de6d6b908
  1. 1
      lib/composer/composer/autoload_classmap.php
  2. 1
      lib/composer/composer/autoload_static.php
  3. 15
      lib/private/Calendar/CalendarEventBuilder.php
  4. 19
      lib/public/Calendar/CalendarEventStatus.php
  5. 7
      lib/public/Calendar/ICalendarEventBuilder.php
  6. 4
      openapi.json
  7. 1
      tests/data/ics/event-builder-complete.ics
  8. 1
      tests/data/ics/event-builder-without-attendees.ics
  9. 5
      tests/lib/Calendar/CalendarEventBuilderTest.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',

@ -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',

@ -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);
}

@ -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';
};

@ -65,6 +65,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!

@ -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"
},

@ -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

@ -8,6 +8,7 @@ DTSTAMP:20250105T000000Z
SUMMARY:My event
DTSTART:20250105T170958Z
DTEND:20250105T171958Z
STATUS:CONFIRMED
DESCRIPTION:Foo bar baz
END:VEVENT
END:VCALENDAR

@ -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');

Loading…
Cancel
Save