diff options
author | Joas Schilling <coding@schilljs.com> | 2019-09-19 16:09:50 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2019-09-19 16:23:55 +0300 |
commit | 57747a0d7ae43418fa241c8bf8c0b5d4378b4466 (patch) | |
tree | 05ecac787a2f044a82373e77818f47d7b850c673 /lib/Participant.php | |
parent | 2ea6dac6ab52838886ca509fc44599662cca4640 (diff) |
Move the "can start call" functionality into a method
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Participant.php')
-rw-r--r-- | lib/Participant.php | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/Participant.php b/lib/Participant.php index bd8ee8c66..fd43553c7 100644 --- a/lib/Participant.php +++ b/lib/Participant.php @@ -25,6 +25,7 @@ declare(strict_types=1); namespace OCA\Talk; use OCP\DB\QueryBuilder\IQueryBuilder; +use OCP\IConfig; use OCP\IDBConnection; class Participant { @@ -47,6 +48,8 @@ class Participant { /** @var IDBConnection */ protected $db; + /** @var IConfig */ + protected $config; /** @var Room */ protected $room; /** @var string */ @@ -71,6 +74,7 @@ class Participant { private $lastJoinedCall; public function __construct(IDBConnection $db, + IConfig $config, Room $room, string $user, int $participantType, @@ -83,6 +87,7 @@ class Participant { int $lastMentionMessage, \DateTime $lastJoinedCall = null) { $this->db = $db; + $this->config = $config; $this->room = $room; $this->user = $user; $this->participantType = $participantType; @@ -222,4 +227,22 @@ class Participant { $this->lastMentionMessage = $messageId; return true; } + + public function canStartCall(): bool { + $defaultStartCall = (int) $this->config->getAppValue('spreed', 'start_calls', Room::START_CALL_EVERYONE); + + if ($defaultStartCall === Room::START_CALL_EVERYONE) { + return true; + } + + if ($defaultStartCall === Room::START_CALL_USERS && (!$this->isGuest() || $this->hasModeratorPermissions())) { + return true; + } + + if ($defaultStartCall === Room::START_CALL_MODERATORS && $this->hasModeratorPermissions()) { + return true; + } + + return false; + } } |