mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 06:08:46 -04:00
feat(user_status): Add online status type for OpenAPI
Signed-off-by: provokateurin <kate@provokateurin.de>
This commit is contained in:
parent
b15b12d5ec
commit
cbc27d3ca7
4 changed files with 21 additions and 3 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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{
|
||||
|
|
|
|||
|
|
@ -188,9 +188,20 @@
|
|||
"nullable": true
|
||||
},
|
||||
"status": {
|
||||
"type": "string"
|
||||
"$ref": "#/components/schemas/Type"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"online",
|
||||
"away",
|
||||
"dnd",
|
||||
"busy",
|
||||
"offline",
|
||||
"invisible"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue