File tree Expand file tree Collapse file tree 4 files changed +21
-3
lines changed
Expand file tree Collapse file tree 4 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 3939use OCP \UserStatus \IUserStatus ;
4040
4141/**
42+ * @psalm-import-type UserStatusType from ResponseDefinitions
4243 * @psalm-import-type UserStatusPublic from ResponseDefinitions
4344 */
4445class 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 ;
Original file line number Diff line number Diff line change 4747use Psr \Log \LoggerInterface ;
4848
4949/**
50+ * @psalm-import-type UserStatusType from ResponseDefinitions
5051 * @psalm-import-type UserStatusPrivate from ResponseDefinitions
5152 */
5253class 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 }
Original file line number Diff line number Diff line change 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{
Original file line number Diff line number Diff line change 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 },
You can’t perform that action at this time.
0 commit comments