From 0c57a68449789acb51b7237e8a0164e21323065a Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Fri, 8 May 2020 14:46:17 +0200 Subject: Remove talk:room:list command due to privacy concerns Signed-off-by: Daniel Rudolf --- lib/Command/Room/ListCommand.php | 107 --------------------------------------- 1 file changed, 107 deletions(-) delete mode 100644 lib/Command/Room/ListCommand.php (limited to 'lib') diff --git a/lib/Command/Room/ListCommand.php b/lib/Command/Room/ListCommand.php deleted file mode 100644 index be091a914..000000000 --- a/lib/Command/Room/ListCommand.php +++ /dev/null @@ -1,107 +0,0 @@ - - * - * @author Daniel Rudolf - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - -namespace OCA\Talk\Command\Room; - -use OC\Core\Command\Base; -use OCA\Talk\Manager; -use OCA\Talk\Room; -use OCP\IConfig; -use Symfony\Component\Console\Helper\Table; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; - -class ListCommand extends Base { - /** @var Manager */ - public $manager; - - public function __construct(Manager $manager) { - parent::__construct(); - - $this->manager = $manager; - } - - protected function configure(): void { - parent::configure(); - - $this - ->setName('talk:room:list') - ->setDescription('Lists all rooms') - ->addArgument( - 'user', - InputArgument::REQUIRED, - 'Lists all rooms of the given user' - ); - } - - protected function execute(InputInterface $input, OutputInterface $output): ?int { - $userId = $input->getArgument('user'); - - $outputFormat = $input->getOption('output'); - - $result = []; - foreach ($this->manager->getRoomsForParticipant($userId) as $room) { - if (!in_array($room->getType(), [Room::GROUP_CALL, Room::PUBLIC_CALL], true)) { - continue; - } - - $public = $room->getType() === Room::PUBLIC_CALL; - $readOnly = $room->getReadOnly() === Room::READ_ONLY; - $password = $room->hasPassword(); - $lastActivity = $room->getLastActivity(); - - if ($outputFormat === Base::OUTPUT_FORMAT_PLAIN) { - $public = $public ? 'yes' : 'no'; - $readOnly = $readOnly ? 'yes' : 'no'; - $password = $password ? 'yes' : 'no'; - $lastActivity = $lastActivity ? $lastActivity->format('c') : ''; - } else { - $lastActivity = $lastActivity ? (int) $lastActivity->format('U') : null; - } - - $result[] = [ - 'token' => $room->getToken(), - 'name' => $room->getName(), - 'public' => $public, - 'readOnly' => $readOnly, - 'password' => $password, - 'users' => $room->getNumberOfParticipants(), - 'moderators' => $room->getNumberOfModerators(), - 'lastActivity' => $lastActivity, - ]; - } - - if ($outputFormat === Base::OUTPUT_FORMAT_PLAIN) { - (new Table($output)) - ->setHeaders(['token', 'name', 'public', 'readOnly', 'password', 'users', 'moderators', 'lastActivity']) - ->addRows($result) - ->render(); - } else { - $this->writeArrayInOutputFormat($input, $output, $result); - } - - return 0; - } -} -- cgit v1.2.3