diff options
author | Kate <26026535+provokateurin@users.noreply.github.com> | 2024-01-10 09:57:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-10 09:57:46 +0100 |
commit | 50aeae6a858094d86d93d0db12889ca98d226ab0 (patch) | |
tree | 2b714735d16cfcf44630835bf2146754d4756380 /apps/user_status | |
parent | c4d233a8922f77f956964c2f11729e71bed32e83 (diff) | |
parent | cbc27d3ca7a0c17ca0f95b5618c7b997b02af63f (diff) | |
download | nextcloud-server-50aeae6a858094d86d93d0db12889ca98d226ab0.tar.gz nextcloud-server-50aeae6a858094d86d93d0db12889ca98d226ab0.zip |
Merge pull request #42527 from nextcloud/feat/user_status/online-status-type
Diffstat (limited to 'apps/user_status')
-rw-r--r-- | apps/user_status/lib/Controller/StatusesController.php | 2 | ||||
-rw-r--r-- | apps/user_status/lib/Controller/UserStatusController.php | 5 | ||||
-rw-r--r-- | apps/user_status/lib/ResponseDefinitions.php | 4 | ||||
-rw-r--r-- | apps/user_status/openapi.json | 13 |
4 files changed, 21 insertions, 3 deletions
diff --git a/apps/user_status/lib/Controller/StatusesController.php b/apps/user_status/lib/Controller/StatusesController.php index ff9008d1b70..b506a691a61 100644 --- a/apps/user_status/lib/Controller/StatusesController.php +++ b/apps/user_status/lib/Controller/StatusesController.php @@ -39,6 +39,7 @@ use OCP\IRequest; use OCP\UserStatus\IUserStatus; /** + * @psalm-import-type UserStatusType from ResponseDefinitions * @psalm-import-type UserStatusPublic from ResponseDefinitions */ class StatusesController extends OCSController { @@ -105,6 +106,7 @@ class StatusesController extends OCSController { * @return UserStatusPublic */ private function formatStatus(UserStatus $status): array { + /** @var UserStatusType $visibleStatus */ $visibleStatus = $status->getStatus(); if ($visibleStatus === IUserStatus::INVISIBLE) { $visibleStatus = IUserStatus::OFFLINE; diff --git a/apps/user_status/lib/Controller/UserStatusController.php b/apps/user_status/lib/Controller/UserStatusController.php index a85f4f1353a..d06370a19ea 100644 --- a/apps/user_status/lib/Controller/UserStatusController.php +++ b/apps/user_status/lib/Controller/UserStatusController.php @@ -47,6 +47,7 @@ use OCP\IRequest; use Psr\Log\LoggerInterface; /** + * @psalm-import-type UserStatusType from ResponseDefinitions * @psalm-import-type UserStatusPrivate from ResponseDefinitions */ class UserStatusController extends OCSController { @@ -207,6 +208,8 @@ class UserStatusController extends OCSController { * @return UserStatusPrivate */ private function formatStatus(UserStatus $status): array { + /** @var UserStatusType $visibleStatus */ + $visibleStatus = $status->getStatus(); return [ 'userId' => $status->getUserId(), 'message' => $status->getCustomMessage(), @@ -214,7 +217,7 @@ class UserStatusController extends OCSController { 'messageIsPredefined' => $status->getMessageId() !== null, 'icon' => $status->getCustomIcon(), 'clearAt' => $status->getClearAt(), - 'status' => $status->getStatus(), + 'status' => $visibleStatus, 'statusIsUserDefined' => $status->getIsUserDefined(), ]; } diff --git a/apps/user_status/lib/ResponseDefinitions.php b/apps/user_status/lib/ResponseDefinitions.php index f73e5f3b0d9..b5855b39538 100644 --- a/apps/user_status/lib/ResponseDefinitions.php +++ b/apps/user_status/lib/ResponseDefinitions.php @@ -42,12 +42,14 @@ namespace OCA\UserStatus; * visible: ?bool, * } * + * @psalm-type UserStatusType = "online"|"away"|"dnd"|"busy"|"offline"|"invisible" + * * @psalm-type UserStatusPublic = array{ * userId: string, * message: ?string, * icon: ?string, * clearAt: ?int, - * status: string, + * status: UserStatusType, * } * * @psalm-type UserStatusPrivate = UserStatusPublic&array{ diff --git a/apps/user_status/openapi.json b/apps/user_status/openapi.json index 0688f644a43..2d76f8760ee 100644 --- a/apps/user_status/openapi.json +++ b/apps/user_status/openapi.json @@ -188,9 +188,20 @@ "nullable": true }, "status": { - "type": "string" + "$ref": "#/components/schemas/Type" } } + }, + "Type": { + "type": "string", + "enum": [ + "online", + "away", + "dnd", + "busy", + "offline", + "invisible" + ] } } }, |