From 35c4bfd64e0f20d0da5b2f7ce3a8b174a1b61ab4 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Wed, 11 Dec 2024 10:19:58 +0100 Subject: [PATCH 1/4] fix(user_status): Use constraint for findAll() offset Signed-off-by: provokateurin --- apps/user_status/lib/Controller/StatusesController.php | 2 +- apps/user_status/openapi.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/user_status/lib/Controller/StatusesController.php b/apps/user_status/lib/Controller/StatusesController.php index e27a0fabbed99..44688c390232b 100644 --- a/apps/user_status/lib/Controller/StatusesController.php +++ b/apps/user_status/lib/Controller/StatusesController.php @@ -46,7 +46,7 @@ public function __construct( * Find statuses of users * * @param int|null $limit Maximum number of statuses to find - * @param int|null $offset Offset for finding statuses + * @param non-negative-int|null $offset Offset for finding statuses * @return DataResponse, array{}> * * 200: Statuses returned diff --git a/apps/user_status/openapi.json b/apps/user_status/openapi.json index 8b631156709cc..580f17e334dff 100644 --- a/apps/user_status/openapi.json +++ b/apps/user_status/openapi.json @@ -442,7 +442,8 @@ "schema": { "type": "integer", "format": "int64", - "nullable": true + "nullable": true, + "minimum": 0 } }, { From 654a7d22ff714c4a5a0769bb9d32a509cbb39ac3 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Wed, 11 Dec 2024 10:20:48 +0100 Subject: [PATCH 2/4] fix(user_status): Allow null userId in UserStatusController Signed-off-by: provokateurin --- apps/user_status/lib/Controller/UserStatusController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/user_status/lib/Controller/UserStatusController.php b/apps/user_status/lib/Controller/UserStatusController.php index a65f9a75c9f98..da39710b3fbd5 100644 --- a/apps/user_status/lib/Controller/UserStatusController.php +++ b/apps/user_status/lib/Controller/UserStatusController.php @@ -36,7 +36,7 @@ class UserStatusController extends OCSController { public function __construct( string $appName, IRequest $request, - private string $userId, + private ?string $userId, private LoggerInterface $logger, private StatusService $service, private CalendarStatusService $calendarStatusService, From 5c360e0367da488febba66325082158725207801 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Wed, 11 Dec 2024 10:23:02 +0100 Subject: [PATCH 3/4] fix(user_status): Catch non-existing user status when setting custom user status Signed-off-by: provokateurin --- .../lib/Controller/UserStatusController.php | 3 ++ apps/user_status/openapi.json | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/apps/user_status/lib/Controller/UserStatusController.php b/apps/user_status/lib/Controller/UserStatusController.php index da39710b3fbd5..9b3807ce86eed 100644 --- a/apps/user_status/lib/Controller/UserStatusController.php +++ b/apps/user_status/lib/Controller/UserStatusController.php @@ -123,6 +123,7 @@ public function setPredefinedMessage(string $messageId, * @param int|null $clearAt When the message should be cleared * @return DataResponse * @throws OCSBadRequestException The clearAt or icon is invalid or the message is too long + * @throws OCSNotFoundException No status for the current user * * 200: The message was updated successfully */ @@ -149,6 +150,8 @@ public function setCustomMessage(?string $statusIcon, } catch (StatusMessageTooLongException $ex) { $this->logger->debug('New user-status for "' . $this->userId . '" was rejected due to a too long status message.'); throw new OCSBadRequestException($ex->getMessage(), $ex); + } catch (DoesNotExistException $ex) { + throw new OCSNotFoundException('No status for the current user'); } } diff --git a/apps/user_status/openapi.json b/apps/user_status/openapi.json index 580f17e334dff..861ba343aba08 100644 --- a/apps/user_status/openapi.json +++ b/apps/user_status/openapi.json @@ -1016,6 +1016,34 @@ } } } + }, + "404": { + "description": "No status for the current user", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } } } } From e8e5bd6161a1fbe6d81622bce47bc69c69fd6eb4 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Wed, 11 Dec 2024 10:23:49 +0100 Subject: [PATCH 4/4] fix(user_status): Remove non-existent "visible" field from UserStatusPredefined Signed-off-by: provokateurin --- apps/user_status/lib/ResponseDefinitions.php | 1 - apps/user_status/openapi.json | 7 +------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/apps/user_status/lib/ResponseDefinitions.php b/apps/user_status/lib/ResponseDefinitions.php index 6668c40b917c3..82f606dd301ee 100644 --- a/apps/user_status/lib/ResponseDefinitions.php +++ b/apps/user_status/lib/ResponseDefinitions.php @@ -22,7 +22,6 @@ * icon: string, * message: string, * clearAt: ?UserStatusClearAt, - * visible: ?bool, * } * * @psalm-type UserStatusType = "online"|"away"|"dnd"|"busy"|"offline"|"invisible" diff --git a/apps/user_status/openapi.json b/apps/user_status/openapi.json index 861ba343aba08..a0d30693e370c 100644 --- a/apps/user_status/openapi.json +++ b/apps/user_status/openapi.json @@ -111,8 +111,7 @@ "id", "icon", "message", - "clearAt", - "visible" + "clearAt" ], "properties": { "id": { @@ -127,10 +126,6 @@ "clearAt": { "$ref": "#/components/schemas/ClearAt", "nullable": true - }, - "visible": { - "type": "boolean", - "nullable": true } } },