Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Rudolf <github.com@daniel-rudolf.de>2020-05-21 13:18:47 +0300
committerDaniel Rudolf <github.com@daniel-rudolf.de>2020-05-21 13:18:47 +0300
commitbbdfc442f2c2401c514c8160fbaf5fd486c3d2c2 (patch)
treeb076c4dc6a982e79ead39d3a3088ed3d0741c89e /lib
parentdb4caaf2aee8b437798cb7388c59335263e6c063 (diff)
Implement TRoomCommand::completeParticipantValues()
Signed-off-by: Daniel Rudolf <github.com@daniel-rudolf.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/Command/Room/TRoomCommand.php21
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/Command/Room/TRoomCommand.php b/lib/Command/Room/TRoomCommand.php
index bffa4e5e6..df598a6e2 100644
--- a/lib/Command/Room/TRoomCommand.php
+++ b/lib/Command/Room/TRoomCommand.php
@@ -27,12 +27,14 @@ namespace OCA\Talk\Command\Room;
use InvalidArgumentException;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
+use OCA\Talk\Exceptions\RoomNotFoundException;
use OCA\Talk\Manager;
use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCP\IGroup;
use OCP\IUser;
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
+use Symfony\Component\Console\Input\ArgvInput;
trait TRoomCommand {
/**
@@ -325,7 +327,22 @@ trait TRoomCommand {
}
protected function completeParticipantValues(CompletionContext $context): array {
- // TODO: implement me!
- return [];
+ /** @var Manager $roomManager */
+ $roomManager = \OC::$server->query(Manager::class);
+
+ // drop `./occ talk:room:*`, but re-prepend command name for ArgvInput
+ $args = array_merge([$context->getWordAtIndex(0)], array_slice($context->getWords(), 2));
+ $input = new ArgvInput($args, $this->getDefinition());
+
+ try {
+ $token = $input->getArgument('token');
+ $room = $roomManager->getRoomByToken($token);
+ } catch (RoomNotFoundException $e) {
+ return [];
+ }
+
+ return array_map(function (Participant $participant) {
+ return $participant->getUser();
+ }, $room->searchParticipants($context->getCurrentWord()));
}
}