feat: OCC and OCS Calendar Import/Export#49995
feat: OCC and OCS Calendar Import/Export#49995SebastianKrupinski wants to merge 1 commit intomasterfrom
Conversation
b0ee614 to
5198d6b
Compare
c69a4fb to
8a6dd83
Compare
|
Hi @tcitworld I was wondering if you would be willing to test this out with some of your larger live data calendars? |
59a2223 to
67dc029
Compare
67dc029 to
8ad0991
Compare
8ad0991 to
213c1aa
Compare
a2f9ff4 to
8eff6e4
Compare
ChristophWurst
left a comment
There was a problem hiding this comment.
First round of feedback
|
When adding a new controller for HTTP routes I'm wondering if we shouldn't got for OCS and openapi specs right away. Could you please check how doable that is with the different input/output formats you want to support? |
|
Found a new internal use for this, this morning, calendar subscriptions can use the same import code to reduce redundant code, complexity and increase performance. |
I think we can make it work, Import is good already, just struggling getting a proper phpdoc export |
719db50 to
364b0e6
Compare
Done |
|
Failed tests unrelated. The OpenApi test will clear up after... nextcloud/openapi-extractor#213 |
| use OCP\AppFramework\Http; | ||
|
|
||
| /** | ||
| * Class StreamResponse |
There was a problem hiding this comment.
Outdated. Drop this first line if it just duplicates the class name
| $this->generator = $generator; | ||
|
|
||
| $this->setStatus($status); | ||
| $this->cacheFor(0); |
There was a problem hiding this comment.
I don't see this for other app framework responses. would it make sense to move this into your new usages where you don't want caching?
There was a problem hiding this comment.
Done, made it an option
😞 Sorry, I was just trying to keep it up to date, there was 100+ changes on master. |
|
I recommend to familiarize yourself with https://git-scm.com/docs/git-merge#_description. If you need input on specific sections of your changes let me know. I'll wait for the second reviewer before going through the full diff another time. |
There are no more changes on my end, the only changes are they ones you asked for. |
|
Okay, then I'll leave this for the second reviewer. |
| */ | ||
| private function exportStart(string $format): string { | ||
| return match ($format) { | ||
| 'jcal' => '["vcalendar",[["version",{},"text","2.0"],["prodid",{},"text","-\/\/IDN nextcloud.com\/\/Calendar App\/\/EN"]],[', |
There was a problem hiding this comment.
Change prodid to something specific so we can know where the content comes from (something like nextcloud.com/Calendar Export Service).
There was a problem hiding this comment.
Sure, can do that.
| $calendars = $this->calendarManager->getCalendarsForPrincipal('principals/users/' . $userId, [$calendarId]); | ||
| if ($calendars === []) { | ||
| return new DataResponse(['error' => 'calendar not found'], Http::STATUS_BAD_REQUEST); | ||
| } | ||
| $calendar = $calendars[0]; | ||
| if (!$calendar instanceof ICalendarImport) { | ||
| return new DataResponse(['error' => 'calendar export not supported'], Http::STATUS_BAD_REQUEST); | ||
| } |
There was a problem hiding this comment.
No this is required, but there is a spelling error
| if (!$calendar instanceof ICalendarImport) { | ||
| return new DataResponse(['error' => 'calendar export not supported'], Http::STATUS_BAD_REQUEST); | ||
| } | ||
| // evaluate if requested format is supported and convert to output content type |
| if ($format !== null && !in_array($format, $this->importService::FORMATS)) { | ||
| return new DataResponse(['error' => "Format <$format> is not valid."], Http::STATUS_BAD_REQUEST); | ||
| } else { | ||
| $options->setFormat($format ?? 'ical'); | ||
| } |
There was a problem hiding this comment.
another duplicate code, maybe also leftover ?
There was a problem hiding this comment.
Nope required to confirm input format
|
This is too big to review or test. Please split it. |
11da3e6 to
a6599a6
Compare
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
a6599a6 to
f08b795
Compare
|
Superseded or is there anything left to integrate? |
|
@ChristophWurst This still has the OCS api to create and export calendar events. I'll rebase it and remove the already merged parts of this. |


Summary
This adds the ability to export calendars via the OCS and OCC.
OCC Export
Command: calendar:export
Arguments: userId calendarId format filepath
OCC Import
Command: calendar:import
Arguments: userId calendarId format filepath
Options: errors, validation, supersede, show-created, show-updated, show-skipped, show-errors
OCS Export
Endpoint: /ocs/v2.php/calendar/export
Request: POST
OCS Import
Endpoint: /ocs/v2.php/calendar/import
Request: POST
Performance
Checklist