Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions apps/dav/lib/Controller/OutOfOfficeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\User\IAvailabilityCoordinator;
use function mb_strlen;

/**
* @psalm-import-type DAVOutOfOfficeData from ResponseDefinitions
Expand Down Expand Up @@ -120,10 +121,10 @@ public function getOutOfOffice(string $userId): DataResponse {
* @param string $lastDay Last day of the absence in format `YYYY-MM-DD`
* @param string $status Short text that is set as user status during the absence
* @param string $message Longer multiline message that is shown to others during the absence
* @return DataResponse<Http::STATUS_OK, DAVOutOfOfficeData, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: 'firstDay'}, array{}>|DataResponse<Http::STATUS_UNAUTHORIZED, null, array{}>
* @return DataResponse<Http::STATUS_OK, DAVOutOfOfficeData, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: 'firstDay'|'statusLength'}, array{}>|DataResponse<Http::STATUS_UNAUTHORIZED, null, array{}>
*
* 200: Absence data
* 400: When the first day is not before the last day
* 400: When validation fails, e.g. data range error or the first day is not before the last day
* 401: When the user is not logged in
*/
#[NoAdminRequired]
Expand All @@ -137,6 +138,9 @@ public function setOutOfOffice(
if ($user === null) {
return new DataResponse(null, Http::STATUS_UNAUTHORIZED);
}
if (mb_strlen($status) > 100) {
return new DataResponse(['error' => 'statusLength'], Http::STATUS_BAD_REQUEST);
}

$parsedFirstDay = new DateTimeImmutable($firstDay);
$parsedLastDay = new DateTimeImmutable($lastDay);
Expand Down
5 changes: 3 additions & 2 deletions apps/dav/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@
}
},
"400": {
"description": "When the first day is not before the last day",
"description": "When validation fails, e.g. data range error or the first day is not before the last day",
"content": {
"application/json": {
"schema": {
Expand Down Expand Up @@ -652,7 +652,8 @@
"error": {
"type": "string",
"enum": [
"firstDay"
"firstDay",
"statusLength"
]
}
}
Expand Down
Loading