diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-04-05 20:21:02 +0200 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2022-04-07 15:16:34 +0200 |
commit | 1dbe7dafe26f4a11af610f3ce0dea59c31227d78 (patch) | |
tree | d3d23bb86d3b4434c19dd925a97a53db704c8871 /apps/user_status/lib/Controller/HeartbeatController.php | |
parent | 9c84aa5870204a871024ca18b4994ed40defdd9b (diff) | |
download | nextcloud-server-1dbe7dafe26f4a11af610f3ce0dea59c31227d78.tar.gz nextcloud-server-1dbe7dafe26f4a11af610f3ce0dea59c31227d78.zip |
Fetch status in heartbeat controller only once
Store the user status inside the event instead of fetching it again
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'apps/user_status/lib/Controller/HeartbeatController.php')
-rw-r--r-- | apps/user_status/lib/Controller/HeartbeatController.php | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/apps/user_status/lib/Controller/HeartbeatController.php b/apps/user_status/lib/Controller/HeartbeatController.php index 223ff4a0f45..c11a63b4420 100644 --- a/apps/user_status/lib/Controller/HeartbeatController.php +++ b/apps/user_status/lib/Controller/HeartbeatController.php @@ -81,21 +81,21 @@ class HeartbeatController extends Controller { return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR); } - $this->eventDispatcher->dispatchTyped( - new UserLiveStatusEvent( - $user, - $status, - $this->timeFactory->getTime() - ) + $event = new UserLiveStatusEvent( + $user, + $status, + $this->timeFactory->getTime() ); - try { - $userStatus = $this->service->findByUserId($user->getUID()); - } catch (DoesNotExistException $ex) { + $this->eventDispatcher->dispatchTyped($event); + + $userStatus = $event->getUserStatus(); + if (!$userStatus) { return new JSONResponse([], Http::STATUS_NO_CONTENT); } - return new JSONResponse($this->formatStatus($userStatus)); + /** @psalm-suppress UndefinedInterfaceMethod */ + return new JSONResponse($this->formatStatus($userStatus->getInternal())); } private function formatStatus(UserStatus $status): array { |