feat: OCS Calendar Export + Import#55178
Conversation
12ad7af to
6838bbe
Compare
e000a47 to
a3431ef
Compare
provokateurin
left a comment
There was a problem hiding this comment.
The code comments in the controller are a bit useless, you might want to remove them to avoid confusion if the code is refactored later.
| * @param array{rangeStart:string,rangeCount:int<1,max>} $options configuration options | ||
| * @param string|null $user system user id | ||
| * | ||
| * @return StreamGeneratorResponse<Http::STATUS_OK, array{Content-Type:string}> | DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_UNAUTHORIZED, array{error?: non-empty-string}, array{}> |
There was a problem hiding this comment.
I think you could limit the Content-Type type to the possible values, so it's clear in the OpenAPI spec what might be returned.
| #[ApiRoute(verb: 'POST', url: '/export', root: '/calendar')] | ||
| #[UserRateLimit(limit: 60, period: 60)] | ||
| #[NoAdminRequired] | ||
| public function index(string $id, ?string $type = null, ?array $options = null, ?string $user = null) { |
There was a problem hiding this comment.
| public function index(string $id, ?string $type = null, ?array $options = null, ?string $user = null) { | |
| public function export(string $id, ?string $type = null, ?array $options = null, ?string $user = null) { |
| #[ApiRoute(verb: 'POST', url: '/import', root: '/calendar')] | ||
| #[UserRateLimit(limit: 1, period: 60)] | ||
| #[NoAdminRequired] | ||
| public function index(string $id, array $options, string $data, ?string $user = null): DataResponse { |
There was a problem hiding this comment.
| public function index(string $id, array $options, string $data, ?string $user = null): DataResponse { | |
| public function import(string $id, array $options, string $data, ?string $user = null): DataResponse { |
| * | ||
| * @param string $id calendar id | ||
| * @param string|null $type data format | ||
| * @param array{rangeStart:string,rangeCount:int<1,max>} $options configuration options |
There was a problem hiding this comment.
| * @param array{rangeStart:string,rangeCount:int<1,max>} $options configuration options | |
| * @param array{rangeStart:string,rangeCount:positive-int} $options configuration options |
| * Import calendar data | ||
| * | ||
| * @param string $id calendar id | ||
| * @param array{format?:string, validation?:int<0,2>, errors?:int<0,1>, supersede?:bool, showCreated?:bool, showUpdated?:bool, showSkipped?:bool, showErrors?:bool} $options configuration options |
There was a problem hiding this comment.
| * @param array{format?:string, validation?:int<0,2>, errors?:int<0,1>, supersede?:bool, showCreated?:bool, showUpdated?:bool, showSkipped?:bool, showErrors?:bool} $options configuration options | |
| * @param array{format?:string, validation?:0|1|2, errors?:0|1, supersede?:bool, showCreated?:bool, showUpdated?:bool, showSkipped?:bool, showErrors?:bool} $options configuration options |
| $format = isset($options['format']) ? $options['format'] : null; | ||
| $validation = isset($options['validation']) ? (int)$options['validation'] : null; | ||
| $errors = isset($options['errors']) ? (int)$options['errors'] : null; | ||
| $supersede = $options['supersede'] ?? false; | ||
| $showCreated = $options['showCreated'] ?? false; | ||
| $showUpdated = $options['showUpdated'] ?? false; | ||
| $showSkipped = $options['showSkipped'] ?? false; | ||
| $showErrors = $options['showErrors'] ?? false; |
There was a problem hiding this comment.
Why have this options parameter instead of putting all of them into the parameters right away?
There was a problem hiding this comment.
Makes for nicer json formatting and prevents function parameter bloat.
| * 400: invalid parameters | ||
| * 401: user not authorized | ||
| */ | ||
| #[OpenAPI(scope: OpenAPI::SCOPE_DEFAULT)] |
There was a problem hiding this comment.
| #[OpenAPI(scope: OpenAPI::SCOPE_DEFAULT)] |
Not necessary
| * 400: invalid request | ||
| * 401: user not authorized | ||
| */ | ||
| #[OpenAPI(scope: OpenAPI::SCOPE_DEFAULT)] |
There was a problem hiding this comment.
| #[OpenAPI(scope: OpenAPI::SCOPE_DEFAULT)] |
| use OCP\AppFramework\Http; | ||
|
|
||
| /** | ||
| * @since 32.0.0 |
There was a problem hiding this comment.
| * @since 32.0.0 | |
| * @since 33.0.0 |
All @SInCE are wrong here
| * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-only |
There was a problem hiding this comment.
| * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | |
| * SPDX-License-Identifier: AGPL-3.0-only | |
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | |
| * SPDX-License-Identifier: AGPL-3.0-or-later |
a3431ef to
3e048d5
Compare
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
2ac397f to
20a731c
Compare
Summary
Extracted from #49995
This adds the ability to export and import calendars via the OCS
OCS Export
Endpoint: /ocs/v2.php/calendar/export
Request: POST
OCS Import
Endpoint: /ocs/v2.php/calendar/import
Request: POST
Checklist