-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat: OCS Calendar Export + Import #55178
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
base: master
Are you sure you want to change the base?
Conversation
12ad7af
to
6838bbe
Compare
95ef88c
to
e000a47
Compare
Signed-off-by: SebastianKrupinski <[email protected]>
e000a47
to
a3431ef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have this options parameter instead of putting all of them into the parameters right away?
* 400: invalid parameters | ||
* 401: user not authorized | ||
*/ | ||
#[OpenAPI(scope: OpenAPI::SCOPE_DEFAULT)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[OpenAPI(scope: OpenAPI::SCOPE_DEFAULT)] |
use OCP\AppFramework\Http; | ||
|
||
/** | ||
* @since 32.0.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* 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 |
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