Fix logout failure if active session was removed from room

If the user tries to immediately log out after being removed from a
conversation in which she was active an exception could be thrown during
the logout cleanup if no conversation is found for the session. If the
exception is not caught then the logout will fail.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2020-06-30 14:45:21 +02:00
Родитель b42625f2c9
Коммит c8e8b7bd25
1 изменённых файлов: 11 добавлений и 5 удалений

Просмотреть файл

@ -23,6 +23,8 @@ declare(strict_types=1);
namespace OCA\Talk\Listener;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\Exceptions\RoomNotFoundException;
use OCA\Talk\Manager;
use OCA\Talk\Participant;
use OCA\Talk\TalkSession;
@ -58,12 +60,16 @@ class BeforeUserLoggedOutListener implements IEventListener {
$sessionIds = $this->talkSession->getAllActiveSessions();
foreach ($sessionIds as $sessionId) {
try {
$room = $this->manager->getRoomForSession($user->getUID(), $sessionId);
$participant = $room->getParticipant($user->getUID());
if ($participant->getInCallFlags() !== Participant::FLAG_DISCONNECTED) {
$room->changeInCall($participant, Participant::FLAG_DISCONNECTED);
}
$room->leaveRoom($user->getUID(), $sessionId);
} catch (RoomNotFoundException $e) {
} catch (ParticipantNotFoundException $e) {
}
}
}
}