diff options
author | Carl Schwan <carl@carlschwan.eu> | 2021-11-19 15:09:05 +0100 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2021-11-23 12:21:42 +0100 |
commit | 92fe694b7f088b0aea797b83506e4ad18a061dbf (patch) | |
tree | 05eddd0931cc6b377a0e0c3dc9b56c609526f420 /apps/user_status/lib/Controller | |
parent | c35ad0c20d420c3056565c6bad21133dc035b2df (diff) | |
download | nextcloud-server-92fe694b7f088b0aea797b83506e4ad18a061dbf.tar.gz nextcloud-server-92fe694b7f088b0aea797b83506e4ad18a061dbf.zip |
Fix multiple bugs with user status
* Fix editing the status while on a call, don't send a bogus request
* Clean backup user status when setting up a new status manually
* A bit more type hinting
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'apps/user_status/lib/Controller')
-rw-r--r-- | apps/user_status/lib/Controller/StatusesController.php | 4 | ||||
-rw-r--r-- | apps/user_status/lib/Controller/UserStatusController.php | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/apps/user_status/lib/Controller/StatusesController.php b/apps/user_status/lib/Controller/StatusesController.php index 56dbeb4f7a5..d30389e1716 100644 --- a/apps/user_status/lib/Controller/StatusesController.php +++ b/apps/user_status/lib/Controller/StatusesController.php @@ -87,10 +87,8 @@ class StatusesController extends OCSController { } /** - * @NoAdminRequired - * * @param UserStatus $status - * @return array + * @return array{userId: string, message: string, icon: string, clearAt: int, status: string} */ private function formatStatus(UserStatus $status): array { $visibleStatus = $status->getStatus(); diff --git a/apps/user_status/lib/Controller/UserStatusController.php b/apps/user_status/lib/Controller/UserStatusController.php index a231103e91e..8708a7c2aac 100644 --- a/apps/user_status/lib/Controller/UserStatusController.php +++ b/apps/user_status/lib/Controller/UserStatusController.php @@ -99,6 +99,8 @@ class UserStatusController extends OCSController { public function setStatus(string $statusType): DataResponse { try { $status = $this->service->setStatus($this->userId, $statusType, null, true); + + $this->service->removeBackupUserStatus($this->userId); return new DataResponse($this->formatStatus($status)); } catch (InvalidStatusTypeException $ex) { $this->logger->debug('New user-status for "' . $this->userId . '" was rejected due to an invalid status type "' . $statusType . '"'); @@ -118,6 +120,7 @@ class UserStatusController extends OCSController { ?int $clearAt): DataResponse { try { $status = $this->service->setPredefinedMessage($this->userId, $messageId, $clearAt); + $this->service->removeBackupUserStatus($this->userId); return new DataResponse($this->formatStatus($status)); } catch (InvalidClearAtException $ex) { $this->logger->debug('New user-status for "' . $this->userId . '" was rejected due to an invalid clearAt value "' . $clearAt . '"'); @@ -147,6 +150,7 @@ class UserStatusController extends OCSController { $this->service->clearMessage($this->userId); $status = $this->service->findByUserId($this->userId); } + $this->service->removeBackupUserStatus($this->userId); return new DataResponse($this->formatStatus($status)); } catch (InvalidClearAtException $ex) { $this->logger->debug('New user-status for "' . $this->userId . '" was rejected due to an invalid clearAt value "' . $clearAt . '"'); |