Only do previous participant work when we actually have a session

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2023-01-24 12:36:46 +01:00
parent d277add2c0
commit cbfa72d9f4
No known key found for this signature in database
GPG key ID: 74434EFE0D2E2205

View file

@ -1446,35 +1446,34 @@ class RoomController extends AEnvironmentAwareController {
$previousParticipant = null;
/** @var Session|null $previousSession */
$previousSession = null;
if ($this->userId !== null) {
if ($sessionId !== null) {
try {
$previousParticipant = $this->participantService->getParticipant($room, $this->userId, $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) {
}
} else {
try {
$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);