diff options
author | Daniel Rudolf <github.com@daniel-rudolf.de> | 2020-06-02 22:46:01 +0300 |
---|---|---|
committer | Daniel Rudolf <github.com@daniel-rudolf.de> | 2020-06-02 22:46:01 +0300 |
commit | cebcfefac84715dfe4a88264b0622df5c939cfec (patch) | |
tree | ab830a33ec1961195c61d1f1fe1b0a74611e1ff8 /lib/Command/Room/Promote.php | |
parent | 08b7bf8b2f91b5b53e01f9e59db9a5c6b69d48a1 (diff) | |
parent | 0b13f861f82dd17d2b789f20884b5a4a67c01a6d (diff) |
Merge branch 'feature/cmd-room-followup' into feature/cmd-room-followup-backport19
Diffstat (limited to 'lib/Command/Room/Promote.php')
-rw-r--r-- | lib/Command/Room/Promote.php | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/lib/Command/Room/Promote.php b/lib/Command/Room/Promote.php index 44b378c74..613d8d0b7 100644 --- a/lib/Command/Room/Promote.php +++ b/lib/Command/Room/Promote.php @@ -25,12 +25,11 @@ declare(strict_types=1); namespace OCA\Talk\Command\Room; -use Exception; +use InvalidArgumentException; use OC\Core\Command\Base; use OCA\Talk\Exceptions\RoomNotFoundException; -use OCA\Talk\Manager; use OCA\Talk\Room; -use OCP\IUserManager; +use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -38,19 +37,6 @@ use Symfony\Component\Console\Output\OutputInterface; class Promote extends Base { use TRoomCommand; - /** @var IUserManager */ - public $userManager; - - /** @var Manager */ - public $manager; - - public function __construct(IUserManager $userManager, Manager $manager) { - parent::__construct(); - - $this->userManager = $userManager; - $this->manager = $manager; - } - protected function configure(): void { $this ->setName('talk:room:promote') @@ -84,12 +70,24 @@ class Promote extends Base { try { $this->addRoomModerators($room, $users); - } catch (Exception $e) { + } catch (InvalidArgumentException $e) { $output->writeln(sprintf('<error>%s</error>', $e->getMessage())); return 1; } - $output->writeln('<info>Users successfully added to room.</info>'); + $output->writeln('<info>Participants successfully promoted to moderators.</info>'); return 0; } + + public function completeArgumentValues($argumentName, CompletionContext $context) { + switch ($argumentName) { + case 'token': + return $this->completeTokenValues($context); + + case 'participant': + return $this->completeParticipantValues($context); + } + + return parent::completeArgumentValues($argumentName, $context); + } } |