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
2 changes: 2 additions & 0 deletions apps/user_status/lib/Controller/StatusesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
use OCP\UserStatus\IUserStatus;

/**
* @psalm-import-type UserStatusType from ResponseDefinitions
* @psalm-import-type UserStatusPublic from ResponseDefinitions
*/
class StatusesController extends OCSController {
Expand Down Expand Up @@ -105,6 +106,7 @@ public function find(string $userId): DataResponse {
* @return UserStatusPublic
*/
private function formatStatus(UserStatus $status): array {
/** @var UserStatusType $visibleStatus */
$visibleStatus = $status->getStatus();
if ($visibleStatus === IUserStatus::INVISIBLE) {
$visibleStatus = IUserStatus::OFFLINE;
Expand Down
5 changes: 4 additions & 1 deletion apps/user_status/lib/Controller/UserStatusController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
use Psr\Log\LoggerInterface;

/**
* @psalm-import-type UserStatusType from ResponseDefinitions
* @psalm-import-type UserStatusPrivate from ResponseDefinitions
*/
class UserStatusController extends OCSController {
Expand Down Expand Up @@ -207,14 +208,16 @@ public function revertStatus(string $messageId): DataResponse {
* @return UserStatusPrivate
*/
private function formatStatus(UserStatus $status): array {
/** @var UserStatusType $visibleStatus */
$visibleStatus = $status->getStatus();
return [
'userId' => $status->getUserId(),
'message' => $status->getCustomMessage(),
'messageId' => $status->getMessageId(),
'messageIsPredefined' => $status->getMessageId() !== null,
'icon' => $status->getCustomIcon(),
'clearAt' => $status->getClearAt(),
'status' => $status->getStatus(),
'status' => $visibleStatus,
'statusIsUserDefined' => $status->getIsUserDefined(),
];
}
Expand Down
4 changes: 3 additions & 1 deletion apps/user_status/lib/ResponseDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@
* 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{
Expand Down
13 changes: 12 additions & 1 deletion apps/user_status/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,20 @@
"nullable": true
},
"status": {
"type": "string"
"$ref": "#/components/schemas/Type"
}
}
},
"Type": {
"type": "string",
"enum": [
"online",
"away",
"dnd",
"busy",
"offline",
"invisible"
]
}
}
},
Expand Down