diff options
author | Joas Schilling <coding@schilljs.com> | 2023-01-24 12:36:46 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2023-01-24 12:42:05 +0100 |
commit | cbfa72d9f41f682ffc0a5e7ef17e76eff11321d6 (patch) | |
tree | 555415bd2c3f76585c92cb47a7f4015753ea4439 /lib | |
parent | d277add2c01f24e2be2991bd6b6ed77779ef0d9b (diff) |
Only do previous participant work when we actually have a session
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Controller/RoomController.php | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index d5f350129..1ae553c18 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -1446,35 +1446,34 @@ class RoomController extends AEnvironmentAwareController { $previousParticipant = null; /** @var Session|null $previousSession */ $previousSession = null; - if ($this->userId !== null) { - try { - $previousParticipant = $this->participantService->getParticipant($room, $this->userId, $sessionId); - $previousSession = $previousParticipant->getSession(); - } catch (ParticipantNotFoundException $e) { - } - } else { + + if ($sessionId !== null) { try { - $previousParticipant = $this->participantService->getParticipantBySession($room, $sessionId); + if ($this->userId !== null) { + $previousParticipant = $this->participantService->getParticipant($room, $this->userId, $sessionId); + } else { + $previousParticipant = $this->participantService->getParticipantBySession($room, $sessionId); + } $previousSession = $previousParticipant->getSession(); } catch (ParticipantNotFoundException $e) { } - } - if ($previousSession instanceof Session && $previousSession->getSessionId() !== '0') { - if ($force === false && $previousSession->getInCall() !== Participant::FLAG_DISCONNECTED) { - // Previous session is/was active in the call, show a warning - return new DataResponse([ - 'sessionId' => $previousSession->getSessionId(), - 'inCall' => $previousSession->getInCall(), - 'lastPing' => $previousSession->getLastPing(), - ], Http::STATUS_CONFLICT); - } + if ($previousSession instanceof Session && $previousSession->getSessionId() !== '0') { + if ($force === false && $previousSession->getInCall() !== Participant::FLAG_DISCONNECTED) { + // Previous session is/was active in the call, show a warning + return new DataResponse([ + 'sessionId' => $previousSession->getSessionId(), + 'inCall' => $previousSession->getInCall(), + 'lastPing' => $previousSession->getLastPing(), + ], Http::STATUS_CONFLICT); + } - if ($previousSession->getInCall() !== Participant::FLAG_DISCONNECTED) { - $this->participantService->changeInCall($room, $previousParticipant, Participant::FLAG_DISCONNECTED); - } + if ($previousSession->getInCall() !== Participant::FLAG_DISCONNECTED) { + $this->participantService->changeInCall($room, $previousParticipant, Participant::FLAG_DISCONNECTED); + } - $this->participantService->leaveRoomAsSession($room, $previousParticipant, true); + $this->participantService->leaveRoomAsSession($room, $previousParticipant, true); + } } $user = $this->userManager->get($this->userId); |