Skip to content

Add an API for calendar providers - #28970

Merged
ChristophWurst merged 1 commit into
masterfrom
enhancement/calendar-appointments
Oct 14, 2021
Merged

Add an API for calendar providers#28970
ChristophWurst merged 1 commit into
masterfrom
enhancement/calendar-appointments

Conversation

@miaulalala

@miaulalalamiaulalala commented Sep 27, 2021

Copy link
Copy Markdown
Contributor

Right now user calendars are preemptively loaded in every request. This comes with two downsides

  • We create calendar objects that are possibly never used
  • Any queries against the calendars always go against the current user's calendars. You can't look into someone elses calendar. You can't look into a calendar from a background or CLI job

This flips the logic so that calendar back-end apps (mainly the dav app but possibly other "virtual" calendars like in deck) register that they provide calendars. Then, when calendars are needed, we ask all the registered providers for the calendars of the given principal, the providers give back a list and that list can be used for the queries.

This means we

  • Don't load anything unless we need it
  • It works in any user context, background jobs and CLI

Todo

  • Deprecate the old preemptive APIs that register calendars or calendar closures
  • Add a new, lazy and user context independent mechanism

Follow-up tasks

Required for nextcloud/calendar#3477

@ChristophWurstChristophWurst changed the title Add Public Calendar ProviderAdd an API for calendar providersSep 27, 2021
Comment threadlib/private/AppFramework/Bootstrap/RegistrationContext.php Outdated
Comment threadlib/public/AppFramework/Bootstrap/IRegistrationContext.php Outdated
Comment threadlib/public/Calendar/ICalendarProvider.php Outdated
Comment threadlib/public/Calendar/ICalendarProvider.php Outdated
Comment threadlib/private/Calendar/Manager.php Outdated
@ChristophWurst
ChristophWurst marked this pull request as draft September 27, 2021 13:14
@ChristophWurstChristophWurst added the pending documentation This pull request needs an associated documentation update label Sep 27, 2021
Comment threadlib/private/Calendar/CalendarQuery.php Outdated
Comment threadlib/private/Calendar/CalendarQuery.php Outdated
}

public function setTimerangeStart(\DateTime $startTime): void {
$this->options['timerange']['start'] = $startTime;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you want to initialize options with an empty array otherwise you access an offset of null here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

timerange is not initialized in the constructor

Comment threadlib/public/Calendar/ICalendarQuery.php Outdated
Comment threadlib/public/Calendar/ICalendarQuery.php Outdated
Comment threadlib/private/Calendar/Manager.php Outdated
Comment threadlib/private/Calendar/CalendarQuery.php Outdated
@miaulalalamiaulalala mentioned this pull request Oct 12, 2021
46 tasks
@ChristophWurst

Copy link
Copy Markdown
Member

Is this ready for a final review? :)

@miaulalalamiaulalala added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Oct 13, 2021
@miaulalala
miaulalalaforce-pushed the enhancement/calendar-appointments branch from d0269da to efc762eCompareOctober 13, 2021 15:26
@miaulalala
miaulalala requested review from a team, ArtificialOwl, ChristophWurst, come-nc, kesselb, nickvergessen and skjnldsv and removed request for a teamOctober 13, 2021 15:26
@ChristophWurst
ChristophWurst marked this pull request as ready for review October 13, 2021 15:27
@ChristophWurst

Copy link
Copy Markdown
Member

@miaulalala please add the deprecations to #27846

@blizzzblizzz removed the 3. to review Waiting for reviews label Oct 13, 2021
Comment threadlib/private/AppFramework/Bootstrap/RegistrationContext.php Outdated
Comment threadlib/private/AppFramework/Bootstrap/RegistrationContext.php Outdated
Comment threadlib/private/AppFramework/Bootstrap/RegistrationContext.php Outdated
Comment threadlib/private/AppFramework/Bootstrap/RegistrationContext.php Outdated
Comment threadapps/dav/lib/CalDAV/CalDavBackend.php
Comment threadapps/dav/lib/CalDAV/CalDavBackend.php Outdated
@kesselbkesselb added 3. to review Waiting for reviews and removed 4. to release Ready to be released and/or waiting for tests to finish labels Oct 13, 2021
@ChristophWurst

This comment has been minimized.

Comment threadapps/dav/lib/CalDAV/CalendarProvider.php
@ChristophWurst
ChristophWurstforce-pushed the enhancement/calendar-appointments branch from efc762e to dfe4c6cCompareOctober 13, 2021 17:42
Comment threadapps/dav/lib/CalDAV/CalendarProvider.php
@ChristophWurst
ChristophWurstforce-pushed the enhancement/calendar-appointments branch from dfe4c6c to 116140bCompareOctober 13, 2021 17:48
@miaulalala
miaulalalaforce-pushed the enhancement/calendar-appointments branch from 116140b to d5025adCompareOctober 13, 2021 17:57
@kesselbkesselb added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Oct 13, 2021

@nickvergessennickvergessen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Look clean

@miaulalala
miaulalalaforce-pushed the enhancement/calendar-appointments branch from d5025ad to 41d5841CompareOctober 13, 2021 18:58
Comment threadlib/private/Calendar/Manager.php
Comment threadlib/public/Calendar/ICalendarQuery.php Outdated
@miaulalala
miaulalalaforce-pushed the enhancement/calendar-appointments branch from 41d5841 to 767e518CompareOctober 13, 2021 20:42
Signed-off-by: Anna Larch <anna@nextcloud.com>
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4. to releaseReady to be released and/or waiting for tests to finishenhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@miaulalala@ChristophWurst@nickvergessen@blizzz@kesselb