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

Calendar API for apps #6840

Merged
merged 6 commits into from
Nov 16, 2017
Merged

Calendar API for apps #6840

merged 6 commits into from
Nov 16, 2017

Conversation

georgehrke
Copy link
Member

implements / fixes #5282

@georgehrke georgehrke added the 2. developing Work in progress label Oct 15, 2017
@georgehrke
Copy link
Member Author

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

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.

@codecov
Copy link

codecov bot commented Oct 16, 2017

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 Files Coverage Δ Complexity Δ
apps/dav/composer/composer/autoload_static.php 0% <ø> (ø) 1 <0> (ø) ⬇️
apps/dav/appinfo/app.php 28.57% <0%> (-11.43%) 0 <0> (ø)
apps/dav/composer/composer/autoload_classmap.php 0% <0%> (ø) 0 <0> (ø) ⬇️
apps/dav/lib/AppInfo/Application.php 20.22% <25%> (-0.71%) 14 <2> (+1)
lib/private/Server.php 83.13% <50%> (-0.16%) 126 <1> (+1)
apps/dav/lib/CalDAV/CalDavBackend.php 84.99% <77.01%> (-0.73%) 242 <23> (+23)
apps/dav/lib/CalDAV/CalendarManager.php 78.57% <78.57%> (ø) 4 <4> (?)
lib/private/Calendar/Manager.php 88.88% <88.88%> (ø) 12 <12> (?)
apps/dav/lib/CalDAV/CalendarImpl.php 96.66% <96.66%> (ø) 10 <10> (?)
... and 2 more

* @return string defining the technical unique key
* @since 13.0.0
*/
public function getKey();
Copy link
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
Member Author

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

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

@georgehrke
Copy link
Member Author

georgehrke commented Oct 16, 2017

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 :)


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

Choose a reason for hiding this comment

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

Why mixed?

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

* @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
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
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
Member Author

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
Member Author

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

public function search($pattern, $searchProperties, $options, $limit, $offset);

/**
* @return mixed
Copy link
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 ;-)

namespace OCP\Calendar;

/**
* This class provides access to the calendar app.
Copy link
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
Member Author

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 georgehrke force-pushed the feature/5282/calendar_api branch 2 times, most recently from 89be19e to d403d30 Compare October 20, 2017 09:15
@georgehrke
Copy link
Member Author

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

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

tcitworld
tcitworld previously approved these changes Oct 29, 2017
Copy link
Member

@tcitworld tcitworld left a comment

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
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
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
Member Author

Choose a reason for hiding this comment

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

done ✅

@georgehrke georgehrke force-pushed the feature/5282/calendar_api branch 2 times, most recently from fbef205 to 26a474d Compare November 7, 2017 01:13
@georgehrke
Copy link
Member Author

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
Member

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

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

Requested changes applied

@georgehrke georgehrke changed the title Public interfaces for calendar API Calendar API for apps Nov 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 georgehrke added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Nov 9, 2017
@georgehrke
Copy link
Member Author

please review @tcitworld @MorrisJobke @LukasReschke :)

@georgehrke georgehrke added this to the Nextcloud 13 milestone Nov 11, 2017
@MorrisJobke MorrisJobke merged commit f32fbbc into master Nov 16, 2017
@MorrisJobke MorrisJobke deleted the feature/5282/calendar_api branch November 16, 2017 20:10
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide Calendar API
6 participants