Skip to content

Commit 9aaead8

Browse files
Merge pull request #42684 from nextcloud/backport/42527/stable28
2 parents 511790d + bb752fa commit 9aaead8

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

apps/user_status/lib/Controller/StatusesController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
use OCP\UserStatus\IUserStatus;
4040

4141
/**
42+
* @psalm-import-type UserStatusType from ResponseDefinitions
4243
* @psalm-import-type UserStatusPublic from ResponseDefinitions
4344
*/
4445
class StatusesController extends OCSController {
@@ -105,6 +106,7 @@ public function find(string $userId): DataResponse {
105106
* @return UserStatusPublic
106107
*/
107108
private function formatStatus(UserStatus $status): array {
109+
/** @var UserStatusType $visibleStatus */
108110
$visibleStatus = $status->getStatus();
109111
if ($visibleStatus === IUserStatus::INVISIBLE) {
110112
$visibleStatus = IUserStatus::OFFLINE;

apps/user_status/lib/Controller/UserStatusController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
use Psr\Log\LoggerInterface;
4848

4949
/**
50+
* @psalm-import-type UserStatusType from ResponseDefinitions
5051
* @psalm-import-type UserStatusPrivate from ResponseDefinitions
5152
*/
5253
class UserStatusController extends OCSController {
@@ -207,14 +208,16 @@ public function revertStatus(string $messageId): DataResponse {
207208
* @return UserStatusPrivate
208209
*/
209210
private function formatStatus(UserStatus $status): array {
211+
/** @var UserStatusType $visibleStatus */
212+
$visibleStatus = $status->getStatus();
210213
return [
211214
'userId' => $status->getUserId(),
212215
'message' => $status->getCustomMessage(),
213216
'messageId' => $status->getMessageId(),
214217
'messageIsPredefined' => $status->getMessageId() !== null,
215218
'icon' => $status->getCustomIcon(),
216219
'clearAt' => $status->getClearAt(),
217-
'status' => $status->getStatus(),
220+
'status' => $visibleStatus,
218221
'statusIsUserDefined' => $status->getIsUserDefined(),
219222
];
220223
}

apps/user_status/lib/ResponseDefinitions.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,14 @@
4242
* visible: ?bool,
4343
* }
4444
*
45+
* @psalm-type UserStatusType = "online"|"away"|"dnd"|"busy"|"offline"|"invisible"
46+
*
4547
* @psalm-type UserStatusPublic = array{
4648
* userId: string,
4749
* message: ?string,
4850
* icon: ?string,
4951
* clearAt: ?int,
50-
* status: string,
52+
* status: UserStatusType,
5153
* }
5254
*
5355
* @psalm-type UserStatusPrivate = UserStatusPublic&array{

apps/user_status/openapi.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,20 @@
188188
"nullable": true
189189
},
190190
"status": {
191-
"type": "string"
191+
"$ref": "#/components/schemas/Type"
192192
}
193193
}
194+
},
195+
"Type": {
196+
"type": "string",
197+
"enum": [
198+
"online",
199+
"away",
200+
"dnd",
201+
"busy",
202+
"offline",
203+
"invisible"
204+
]
194205
}
195206
}
196207
},

0 commit comments

Comments
 (0)