fix(occ): Use user instead of accounts to stay in line with other occ

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling
2025-04-01 15:51:09 +02:00
parent 1b79199c7d
commit b62c6b0420
7 changed files with 41 additions and 41 deletions

View File

@ -103,7 +103,7 @@
<command>OCA\Talk\Command\PhoneNumber\AddPhoneNumber</command> <command>OCA\Talk\Command\PhoneNumber\AddPhoneNumber</command>
<command>OCA\Talk\Command\PhoneNumber\FindPhoneNumber</command> <command>OCA\Talk\Command\PhoneNumber\FindPhoneNumber</command>
<command>OCA\Talk\Command\PhoneNumber\ImportPhoneNumbers</command> <command>OCA\Talk\Command\PhoneNumber\ImportPhoneNumbers</command>
<command>OCA\Talk\Command\PhoneNumber\RemoveAccount</command> <command>OCA\Talk\Command\PhoneNumber\RemoveUser</command>
<command>OCA\Talk\Command\PhoneNumber\RemovePhoneNumber</command> <command>OCA\Talk\Command\PhoneNumber\RemovePhoneNumber</command>
<command>OCA\Talk\Command\Recording\Consent</command> <command>OCA\Talk\Command\Recording\Consent</command>

View File

@ -149,37 +149,37 @@ Prints the number of attendees, active sessions and participant in the call.
## talk:phone-number:add ## talk:phone-number:add
Add a mapping entry to map a phone number to an account Add a mapping entry to map a phone number to an user
### Usage ### Usage
* `talk:phone-number:add [-f|--force] [--] <phone> <account>` * `talk:phone-number:add [-f|--force] [--] <phone> <user>`
| Arguments | Description | Is required | Is array | Default | | Arguments | Description | Is required | Is array | Default |
|---|---|---|---|---| |---|---|---|---|---|
| `phone` | Phone number that will be called | yes | no | *Required* | | `phone` | Phone number that will be called | yes | no | *Required* |
| `account` | Account to be added to the conversation | yes | no | *Required* | | `user` | User to be added to the conversation | yes | no | *Required* |
| Options | Description | Accept value | Is value required | Is multiple | Default | | Options | Description | Accept value | Is value required | Is multiple | Default |
|---|---|---|---|---|---| |---|---|---|---|---|---|
| `--force\|-f` | Force the number to the given account even when it is assigned already | no | no | no | `false` | | `--force\|-f` | Force the number to the given user even when it is assigned already | no | no | no | `false` |
## talk:phone-number:find ## talk:phone-number:find
Find a phone number or the phone number of an account Find a phone number or the phone number of an user
### Usage ### Usage
* `talk:phone-number:find [--phone PHONE] [--account ACCOUNT]` * `talk:phone-number:find [--phone PHONE] [--user USER]`
| Options | Description | Accept value | Is value required | Is multiple | Default | | Options | Description | Accept value | Is value required | Is multiple | Default |
|---|---|---|---|---|---| |---|---|---|---|---|---|
| `--phone` | Phone number to search for | yes | yes | no | *Required* | | `--phone` | Phone number to search for | yes | yes | no | *Required* |
| `--account` | Account to get number(s) for | yes | yes | no | *Required* | | `--user` | User to get number(s) for | yes | yes | no | *Required* |
## talk:phone-number:import ## talk:phone-number:import
Import a CSV list (format: "number","account") for SIP dial-in Import a CSV list (format: "number","user") for SIP dial-in
### Usage ### Usage
@ -188,19 +188,19 @@ Import a CSV list (format: "number","account") for SIP dial-in
| Options | Description | Accept value | Is value required | Is multiple | Default | | Options | Description | Accept value | Is value required | Is multiple | Default |
|---|---|---|---|---|---| |---|---|---|---|---|---|
| `--reset` | Delete all phone numbers before importing | no | no | no | `false` | | `--reset` | Delete all phone numbers before importing | no | no | no | `false` |
| `--force\|-f` | Force the numbers to the given account even when they are assigned already | no | no | no | `false` | | `--force\|-f` | Force the numbers to the given user even when they are assigned already | no | no | no | `false` |
## talk:phone-number:remove-account ## talk:phone-number:remove-user
Remove mapping entries by account Remove mapping entries by user
### Usage ### Usage
* `talk:phone-number:remove-account <account>` * `talk:phone-number:remove-user <user>`
| Arguments | Description | Is required | Is array | Default | | Arguments | Description | Is required | Is array | Default |
|---|---|---|---|---| |---|---|---|---|---|
| `account` | Account to remove all mapping entries for | yes | no | *Required* | | `user` | User to remove all mapping entries for | yes | no | *Required* |
## talk:phone-number:remove ## talk:phone-number:remove

View File

@ -34,41 +34,41 @@ class AddPhoneNumber extends Base {
protected function configure(): void { protected function configure(): void {
$this $this
->setName('talk:phone-number:add') ->setName('talk:phone-number:add')
->setDescription('Add a mapping entry to map a phone number to an account') ->setDescription('Add a mapping entry to map a phone number to an user')
->addArgument( ->addArgument(
'phone', 'phone',
InputArgument::REQUIRED, InputArgument::REQUIRED,
'Phone number that will be called', 'Phone number that will be called',
) )
->addArgument( ->addArgument(
'account', 'user',
InputArgument::REQUIRED, InputArgument::REQUIRED,
'Account to be added to the conversation', 'User to be added to the conversation',
) )
->addOption( ->addOption(
'force', 'force',
'f', 'f',
InputOption::VALUE_NONE, InputOption::VALUE_NONE,
'Force the number to the given account even when it is assigned already', 'Force the number to the given user even when it is assigned already',
) )
; ;
} }
protected function execute(InputInterface $input, OutputInterface $output): int { protected function execute(InputInterface $input, OutputInterface $output): int {
$phoneNumber = $input->getArgument('phone'); $phoneNumber = $input->getArgument('phone');
$userId = $input->getArgument('account'); $userId = $input->getArgument('user');
$force = (bool)$input->getOption('force'); $force = (bool)$input->getOption('force');
$user = $this->userManager->get($userId); $user = $this->userManager->get($userId);
if (!$user instanceof IUser) { if (!$user instanceof IUser) {
$output->writeln('<error>Invalid account "' . $userId . '" provided</error>'); $output->writeln('<error>Invalid user "' . $userId . '" provided</error>');
return self::FAILURE; return self::FAILURE;
} }
$userId = $user->getUID(); $userId = $user->getUID();
$phoneNumberStandard = $this->phoneNumberUtil->convertToStandardFormat($phoneNumber); $phoneNumberStandard = $this->phoneNumberUtil->convertToStandardFormat($phoneNumber);
if ($phoneNumberStandard === null) { if ($phoneNumberStandard === null) {
$output->writeln('<error>Invalid phone number ' . $phoneNumber . ' provided</error>'); $output->writeln('<error>Not a valid phone number ' . $phoneNumber . '. The format is invalid.</error>');
return self::FAILURE; return self::FAILURE;
} }
$phoneNumber = $phoneNumberStandard; $phoneNumber = $phoneNumberStandard;

View File

@ -27,7 +27,7 @@ class FindPhoneNumber extends Base {
protected function configure(): void { protected function configure(): void {
$this $this
->setName('talk:phone-number:find') ->setName('talk:phone-number:find')
->setDescription('Find a phone number or the phone number of an account') ->setDescription('Find a phone number or the phone number of an user')
->addOption( ->addOption(
'phone', 'phone',
null, null,
@ -35,17 +35,17 @@ class FindPhoneNumber extends Base {
'Phone number to search for', 'Phone number to search for',
) )
->addOption( ->addOption(
'account', 'user',
null, null,
InputOption::VALUE_REQUIRED, InputOption::VALUE_REQUIRED,
'Account to get number(s) for', 'User to get number(s) for',
) )
; ;
} }
protected function execute(InputInterface $input, OutputInterface $output): int { protected function execute(InputInterface $input, OutputInterface $output): int {
$phoneNumber = (string)$input->getOption('phone'); $phoneNumber = (string)$input->getOption('phone');
$userId = (string)$input->getOption('account'); $userId = (string)$input->getOption('user');
if ($phoneNumber !== '') { if ($phoneNumber !== '') {
try { try {
@ -59,7 +59,7 @@ class FindPhoneNumber extends Base {
} }
if ($userId === '') { if ($userId === '') {
$output->writeln('<error>Neither phone number nor account provided</error>'); $output->writeln('<error>Neither phone number nor user provided</error>');
return self::FAILURE; return self::FAILURE;
} }

View File

@ -34,7 +34,7 @@ class ImportPhoneNumbers extends Base {
protected function configure(): void { protected function configure(): void {
$this $this
->setName('talk:phone-number:import') ->setName('talk:phone-number:import')
->setDescription('Import a CSV list (format: "number","account") for SIP dial-in') ->setDescription('Import a CSV list (format: "number","user") for SIP dial-in')
->addOption( ->addOption(
'reset', 'reset',
null, null,
@ -45,7 +45,7 @@ class ImportPhoneNumbers extends Base {
'force', 'force',
'f', 'f',
InputOption::VALUE_NONE, InputOption::VALUE_NONE,
'Force the numbers to the given account even when they are assigned already', 'Force the numbers to the given user even when they are assigned already',
) )
; ;
} }
@ -74,14 +74,14 @@ class ImportPhoneNumbers extends Base {
$phoneNumberStandard = $this->phoneNumberUtil->convertToStandardFormat($row[0]); $phoneNumberStandard = $this->phoneNumberUtil->convertToStandardFormat($row[0]);
if ($phoneNumberStandard === null) { if ($phoneNumberStandard === null) {
$output->writeln('<error>Invalid phone number ' . $row[0] . ' provided</error>'); $output->writeln('<error>Not a valid phone number ' . $row[0] . '. The format is invalid.</error>');
return self::FAILURE; return self::FAILURE;
} }
$row[0] = $phoneNumberStandard; $row[0] = $phoneNumberStandard;
$user = $this->userManager->get($row[1]); $user = $this->userManager->get($row[1]);
if (!$user instanceof IUser) { if (!$user instanceof IUser) {
$output->writeln('<error>Invalid account "' . $row[1] . '" provided</error>'); $output->writeln('<error>Invalid user "' . $row[1] . '" provided</error>');
return self::FAILURE; return self::FAILURE;
} }
$row[1] = $user->getUID(); $row[1] = $user->getUID();

View File

@ -14,7 +14,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
class RemoveAccount extends Base { class RemoveUser extends Base {
public function __construct( public function __construct(
private PhoneNumberMapper $mapper, private PhoneNumberMapper $mapper,
@ -25,18 +25,18 @@ class RemoveAccount extends Base {
#[\Override] #[\Override]
protected function configure(): void { protected function configure(): void {
$this $this
->setName('talk:phone-number:remove-account') ->setName('talk:phone-number:remove-user')
->setDescription('Remove mapping entries by account') ->setDescription('Remove mapping entries by user')
->addArgument( ->addArgument(
'account', 'user',
InputArgument::REQUIRED, InputArgument::REQUIRED,
'Account to remove all mapping entries for', 'User to remove all mapping entries for',
) )
; ;
} }
protected function execute(InputInterface $input, OutputInterface $output): int { protected function execute(InputInterface $input, OutputInterface $output): int {
$userId = $input->getArgument('account'); $userId = $input->getArgument('user');
$this->mapper->deleteByUser($userId); $this->mapper->deleteByUser($userId);
return self::SUCCESS; return self::SUCCESS;
} }

View File

@ -40,16 +40,16 @@
<code><![CDATA[self::SUCCESS]]></code> <code><![CDATA[self::SUCCESS]]></code>
</UndefinedConstant> </UndefinedConstant>
</file> </file>
<file src="lib/Command/PhoneNumber/RemoveAccount.php">
<UndefinedConstant>
<code><![CDATA[self::SUCCESS]]></code>
</UndefinedConstant>
</file>
<file src="lib/Command/PhoneNumber/RemovePhoneNumber.php"> <file src="lib/Command/PhoneNumber/RemovePhoneNumber.php">
<UndefinedConstant> <UndefinedConstant>
<code><![CDATA[self::SUCCESS]]></code> <code><![CDATA[self::SUCCESS]]></code>
</UndefinedConstant> </UndefinedConstant>
</file> </file>
<file src="lib/Command/PhoneNumber/RemoveUser.php">
<UndefinedConstant>
<code><![CDATA[self::SUCCESS]]></code>
</UndefinedConstant>
</file>
<file src="lib/Config.php"> <file src="lib/Config.php">
<NullArgument> <NullArgument>
<code><![CDATA[null]]></code> <code><![CDATA[null]]></code>