Skip to content

Calendar API for apps - #6840

Merged
MorrisJobke merged 6 commits into
masterfrom
feature/5282/calendar_api
Nov 16, 2017
Merged

Calendar API for apps#6840
MorrisJobke merged 6 commits into
masterfrom
feature/5282/calendar_api

Conversation

@georgehrke

Copy link
Copy Markdown
Member

implements / fixes#5282

@georgehrkegeorgehrke added the 2. developing Work in progress label Oct 15, 2017
@georgehrke

Copy link
Copy Markdown
MemberAuthor

@tcitworld@nickvergessen@MorrisJobke Any comment on the API design? :)

if u give me a 👍 I will go ahead and connect it to the dav app.

@georgehrke

Copy link
Copy Markdown
MemberAuthor

The first version of this API will only allow read-only access, which should already cover >95% of the use cases. If demanded, we can still add write support in a later revision.

@georgehrke
georgehrkeforce-pushed the feature/5282/calendar_api branch from 267390e to 5b04846CompareOctober 16, 2017 08:08
@codecov

codecovBot commented Oct 16, 2017

Copy link
Copy Markdown

Codecov Report

Merging #6840 into master will increase coverage by 0.04%.
The diff coverage is 77.9%.

@@ Coverage Diff @@## master #6840 +/- ##
============================================
+ Coverage 50.74% 50.79% +0.04% - Complexity 24423 24474 +51 
============================================
Files 1580 1583 +3 Lines 93366 93537 +171 Branches 1359 1359 ============================================
+ Hits 47380 47513 +133 - Misses 45986 46024 +38
Impacted FilesCoverage ΔComplexity Δ
apps/dav/composer/composer/autoload_static.php0% <ø> (ø)1 <0> (ø)⬇️
apps/dav/appinfo/app.php28.57% <0%> (-11.43%)0 <0> (ø)
apps/dav/composer/composer/autoload_classmap.php0% <0%> (ø)0 <0> (ø)⬇️
apps/dav/lib/AppInfo/Application.php20.22% <25%> (-0.71%)14 <2> (+1)
lib/private/Server.php83.13% <50%> (-0.16%)126 <1> (+1)
apps/dav/lib/CalDAV/CalDavBackend.php84.99% <77.01%> (-0.73%)242 <23> (+23)
apps/dav/lib/CalDAV/CalendarManager.php78.57% <78.57%> (ø)4 <4> (?)
lib/private/Calendar/Manager.php88.88% <88.88%> (ø)12 <12> (?)
apps/dav/lib/CalDAV/CalendarImpl.php96.66% <96.66%> (ø)10 <10> (?)
... and 2 more

* @return string defining the technical unique key
* @since 13.0.0
*/
public function getKey();

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.

Maybe change this name to something more obvious?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I chose this name for consistency reasons with the contacts api: https://github.com/nextcloud/server/blob/master/lib/public/IAddressBook.php#L46

What other name would u suggest?

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.

Well, I guess I would have gone with something telling it's the ID of the calendar but let's be consistent with the contact api.

@nickvergessen

Copy link
Copy Markdown
Member

This is just a public interface for existing stuff? Or will it implement new features?

@georgehrke

georgehrke commented Oct 16, 2017

Copy link
Copy Markdown
MemberAuthor

This is just a public interface for existing stuff? Or will it implement new features?

I will implement new stuff. The calendar API does not exist yet.
We need something similar to the contacts api.

Edit: I just want to discuss the API design before going ahead and implementing everything :)

LukasReschke
LukasReschke previously requested changes Oct 19, 2017
Comment threadlib/public/Calendar/ICalendar.php Outdated

/**
* In comparison to getKey() this function returns a human readable (maybe translated) name
* @return mixed

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.

Why mixed?

Comment threadlib/public/Calendar/ICalendar.php Outdated
* @return array an array of events/journals/todos which are arrays of key-value-pairs
* @since 13.0.0
*/
public function search($pattern, $searchProperties, $options, $limit, $offset);

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.

Typehint all the arrays

Comment threadlib/public/Calendar/ICalendar.php Outdated
* @param array $options - optional parameters:
* ['timerange' => ['start' => new DateTime(...), 'end' => new DateTime(...)]]
* @param integer|null $limit - limit number of search results
* @param integer $offset - offset for paging of search results

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.

Can that also be null? Because the param above is. Also, you may want to add a default = null in the function definition then.

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.

Or maybe just 0?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Having $offset = null would be semantically equivalent to $offset = 0, which is already covered by integer.

Do we usually allow both null and integer in other APIs?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Ok, according to https://github.com/nextcloud/server/search?utf8=✓&q=integer%7Cnull+%24limit&type= we usually do. So I'll allow both int and null for consistency

Comment threadlib/public/Calendar/ICalendar.php Outdated
public function search($pattern, $searchProperties, $options, $limit, $offset);

/**
* @return mixed

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.

Mixed is so horrible. What can be in here? ;-) - Explaiiin ;-)

Comment threadlib/public/Calendar/IManager.php Outdated
namespace OCP\Calendar;

/**
* This class provides access to the calendar app.

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.

Is it really the calendar app or just the nextcloud caldav backend?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

CalDAV backend indeed, will change

@georgehrke
georgehrkeforce-pushed the feature/5282/calendar_api branch 2 times, most recently from 89be19e to d403d30CompareOctober 20, 2017 09:15
@georgehrke

Copy link
Copy Markdown
MemberAuthor

@LukasReschke If you are happy, I will go ahead with implementing the Calendar Manager and connecting it to the dav app.

Comment threadlib/public/Calendar/ICalendar.php Outdated
* @return array an array of events/journals/todos which are arrays of key-value-pairs
* @since 13.0.0
*/
public function search($pattern, $searchProperties=[], $options=[], $limit, $offset);

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.

From http://php.net/manual/en/functions.arguments.php#functions.arguments.default

Note that when using default arguments, any defaults should be on the right side of any non-default arguments; otherwise, things will not work as expected.

Also I'd suggest to type-hint the two array parameters with array.

@georgehrke
georgehrkeforce-pushed the feature/5282/calendar_api branch from d403d30 to f83215bCompareOctober 23, 2017 16:01
tcitworld
tcitworld previously approved these changes Oct 29, 2017

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

Is there a way to add shares information easily here ?

* @return array
* @since 13.0.0
*/
public function getCalendars();

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.

Array of ICalendar I guess (please precise :) )

* @since 13.0.0
*/
public function getDisplayName();

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.

Maybe add getDisplayColor() or getColor() too since that will probably be used a lot.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

done ✅

@georgehrke
georgehrkeforce-pushed the feature/5282/calendar_api branch from f83215b to 9814821CompareOctober 30, 2017 17:21
@georgehrke
georgehrkeforce-pushed the feature/5282/calendar_api branch 2 times, most recently from fbef205 to 26a474dCompareNovember 7, 2017 01:13
@georgehrke

Copy link
Copy Markdown
MemberAuthor

Is there a way to add shares information easily here ?

What kind of information do you want to request here?
Are u referring to nextcloud/calendar#643 (comment) ?

@tcitworld

Copy link
Copy Markdown
Member

I was thinking more of the people with whom the calendar is shared, but public shares are good too.

@georgehrkegeorgehrke self-assigned this Nov 7, 2017
@georgehrke
georgehrkeforce-pushed the feature/5282/calendar_api branch 2 times, most recently from a4e1206 to 360e9d9CompareNovember 9, 2017 11:44
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
@georgehrke
georgehrkeforce-pushed the feature/5282/calendar_api branch from 360e9d9 to 0b0b85bCompareNovember 9, 2017 12:02
@georgehrke
georgehrke dismissed stale reviews from LukasReschke, ChristophWurst, and tcitworldNovember 9, 2017 12:58

Requested changes applied

@georgehrke
georgehrkeforce-pushed the feature/5282/calendar_api branch from ff9ad26 to 1684ee5CompareNovember 9, 2017 14:11
@georgehrkegeorgehrke changed the title Public interfaces for calendar APICalendar API for appsNov 9, 2017
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
@georgehrke
georgehrkeforce-pushed the feature/5282/calendar_api branch from 1684ee5 to 7784672CompareNovember 9, 2017 14:15
@georgehrkegeorgehrke added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Nov 9, 2017
@georgehrke

Copy link
Copy Markdown
MemberAuthor

please review @tcitworld@MorrisJobke@LukasReschke :)

@georgehrkegeorgehrke added this to the Nextcloud 13 milestone Nov 11, 2017
@MorrisJobke
MorrisJobke merged commit f32fbbc into masterNov 16, 2017
@MorrisJobke
MorrisJobke deleted the feature/5282/calendar_api branch November 16, 2017 20:10
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to reviewWaiting for reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide Calendar API

6 participants

@georgehrke@nickvergessen@tcitworld@MorrisJobke@LukasReschke@ChristophWurst