summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/user_status/lib/Controller/StatusesController.php2
-rw-r--r--apps/user_status/lib/Controller/UserStatusController.php5
-rw-r--r--apps/user_status/lib/ResponseDefinitions.php4
-rw-r--r--apps/user_status/openapi.json13
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 3beb8abc3ab..053b07664a5 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"
+ ]
}
}
},