setName('talk:room:promote')
->setDescription('Promotes participants of a room to moderators')
->addArgument(
'token',
InputArgument::REQUIRED,
'Token of the room in which users should be promoted'
)->addArgument(
'participant',
InputArgument::REQUIRED | InputArgument::IS_ARRAY,
'Promotes the given participants of the room to moderators'
);
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$token = $input->getArgument('token');
$users = $input->getArgument('participant');
try {
$room = $this->manager->getRoomByToken($token);
} catch (RoomNotFoundException $e) {
$output->writeln('Room not found.');
return 1;
}
if ($room->isFederatedConversation()) {
$output->writeln('Room is a federated conversation.');
return 1;
}
if (!in_array($room->getType(), [Room::TYPE_GROUP, Room::TYPE_PUBLIC], true)) {
$output->writeln('Room is no group call.');
return 1;
}
try {
$this->addRoomModerators($room, $users);
} catch (InvalidArgumentException $e) {
$output->writeln(sprintf('%s', $e->getMessage()));
return 1;
}
$output->writeln('Participants successfully promoted to moderators.');
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);
}
}