Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ocp): calendar event builder api #49888

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

st3iny
Copy link
Member

@st3iny st3iny commented Dec 16, 2024

Summary

The event builder API is done and ready to use.

Code example

		$startDate = (new \DateTimeImmutable('now'))
			->setTimezone(new \DateTimeZone('Europe/Berlin'));
		$endDate = $startDate->add(new \DateInterval('PT1H'));
		$builder = $this->calendarManager->createEventBuilder()
			->setStartDate($startDate)
			->setEndDate($endDate)
			->setSummary('An Event')
			->setDescription('With a description')
			->setLocation('Some address') // A URL (of a meeting) would also work
			->setOrganizer('[email protected]')
			->addAttendee('[email protected]')
			->addAttendee('[email protected]', 'User Two');

		// Write the calendar to an event
		/** @var ICreateFromString|ICalendar $calendar */
		$builder->createInCalendar($calendar); // Get calendar from \OCP\Calendar\IManager

		// Or, serialize it to a string to do something else with it
		$ics = $builder->toIcs();

TODO

Checklist

@st3iny st3iny self-assigned this Dec 16, 2024
@st3iny st3iny added feature: caldav Related to CalDAV internals enhancement integration labels Dec 16, 2024
@st3iny st3iny added this to the Nextcloud 31 milestone Dec 16, 2024
@st3iny st3iny added the 2. developing Work in progress label Dec 16, 2024
@st3iny
Copy link
Member Author

st3iny commented Dec 17, 2024

@nickvergessen This should get you started for the meetings feature. Let me know if you have questions.

@nickvergessen nickvergessen changed the title feat(ocp): implemnt required apis to book meetings from talk feat(ocp): implement required apis to book meetings from talk Dec 18, 2024
@st3iny
Copy link
Member Author

st3iny commented Dec 18, 2024

I added a example on how to use the ICalendarEventBuilder API to create an event.

@st3iny st3iny force-pushed the feat/ocp/meetings-api-requirements branch from 3132ecd to b9fbef9 Compare January 5, 2025 15:37
@st3iny st3iny changed the title feat(ocp): implement required apis to book meetings from talk feat(ocp): calendar event builder api Jan 5, 2025
@st3iny st3iny added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Jan 5, 2025
@st3iny st3iny marked this pull request as ready for review January 5, 2025 15:38
@st3iny st3iny force-pushed the feat/ocp/meetings-api-requirements branch 4 times, most recently from 3e6899c to ce5b8a8 Compare January 6, 2025 09:05
Signed-off-by: Richard Steinmetz <[email protected]>
@st3iny st3iny force-pushed the feat/ocp/meetings-api-requirements branch from ce5b8a8 to 80bc1c2 Compare January 6, 2025 09:17
@nickvergessen nickvergessen added pending documentation This pull request needs an associated documentation update and removed needs info labels Jan 7, 2025
Copy link
Member

@nickvergessen nickvergessen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, will implement Talk's side now

use OCP\Calendar\Exceptions\CalendarException;

/**
* The calendar event builder can be used to conveniently build a calendar event and then serialize
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit Could mention that it's not injectable and to get it from {@see IManager::createEventBuilder} ?

@@ -334,3 +334,7 @@ License: CC0-1.0
Files: apps/theming/fonts/OpenDyslexic-Bold.otf apps/theming/fonts/OpenDyslexic-Regular.otf
Copyright: 2012-2019 Abbie Gonzalez <https://abbiecod.es|[email protected]>, with Reserved Font Name OpenDyslexic.
License: OFL-1.1-RFN

Files: tests/data/ics/event-builder-complete.ics tests/data/ics/event-builder-without-attendees.ics
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit should be in a tests/data/ics/event-builder-complete.ics.license file next to it (this way it's dropped when shipping)

* @throws InvalidArgumentException If required properties were not set
* @throws CalendarException If writing the event to the calendar fails
*/
public function createInCalendar(ICreateFromString $calendar): string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Talk we would fed an entry of IManager::getCalendarsForPrincipal() into this, but those are ICalendar not ICreateFromString (which extends it).
Do you need that detail, or could we relax the API?

return $this;
}

public function setSummary(string $summary): ICalendarEventBuilder {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a max length that we should check, or does caldav take care of that, same for description?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews enhancement feature: caldav Related to CalDAV internals integration pending documentation This pull request needs an associated documentation update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants