diff options
author | Joas Schilling <coding@schilljs.com> | 2018-11-09 16:14:57 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2018-11-12 13:35:31 +0300 |
commit | 4afa2d7946f121d07610eeb0165b20ee135fb819 (patch) | |
tree | fe1bd72a5b3772752445355e4fa43766ca715dcf /lib/PublicShareAuth/Listener.php | |
parent | 5448a59d40061f71a279a427b8100079dafc1ecc (diff) |
Do not create the participant when we don't need them
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/PublicShareAuth/Listener.php')
-rw-r--r-- | lib/PublicShareAuth/Listener.php | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/lib/PublicShareAuth/Listener.php b/lib/PublicShareAuth/Listener.php index 11d70905d..b622e2162 100644 --- a/lib/PublicShareAuth/Listener.php +++ b/lib/PublicShareAuth/Listener.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace OCA\Spreed\PublicShareAuth; +use OCA\Spreed\Exceptions\ParticipantNotFoundException; use OCA\Spreed\Participant; use OCA\Spreed\Room; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -92,15 +93,15 @@ class Listener { return; } - $participants = $room->getParticipants(); - $users = $participants['users']; - $guests = $participants['guests']; - - if (array_key_exists($userId, $users) && $users[$userId]['participantType'] === Participant::OWNER) { - return; + try { + $participant = $room->getParticipant($userId); + if ($participant->getParticipantType() === Participant::OWNER) { + return; + } + } catch (ParticipantNotFoundException $e) { } - if (\count($users) > 1 || \count($guests) > 0) { + if ($room->getActiveGuests() > 0 || \count($room->getParticipantUserIds()) > 1) { throw new \OverflowException('Only the owner and another participant are allowed in rooms to request the password for a share'); } } @@ -119,11 +120,7 @@ class Listener { return; } - $participants = $room->getParticipants(); - $users = $participants['users']; - $guests = $participants['guests']; - - if (\count($users) > 1 || \count($guests) > 0) { + if ($room->getActiveGuests() > 0 || \count($room->getParticipantUserIds()) > 1) { throw new \OverflowException('Only the owner and another participant are allowed in rooms to request the password for a share'); } } |