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\FindPhoneNumber</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\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
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
* `talk:phone-number:add [-f|--force] [--] <phone> <account>`
* `talk:phone-number:add [-f|--force] [--] <phone> <user>`
| Arguments | Description | Is required | Is array | Default |
|---|---|---|---|---|
| `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 |
|---|---|---|---|---|---|
| `--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
Find a phone number or the phone number of an account
Find a phone number or the phone number of an user
### 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 |
|---|---|---|---|---|---|
| `--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
Import a CSV list (format: "number","account") for SIP dial-in
Import a CSV list (format: "number","user") for SIP dial-in
### 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 |
|---|---|---|---|---|---|
| `--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
* `talk:phone-number:remove-account <account>`
* `talk:phone-number:remove-user <user>`
| 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

View File

@ -34,41 +34,41 @@ class AddPhoneNumber extends Base {
protected function configure(): void {
$this
->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(
'phone',
InputArgument::REQUIRED,
'Phone number that will be called',
)
->addArgument(
'account',
'user',
InputArgument::REQUIRED,
'Account to be added to the conversation',
'User to be added to the conversation',
)
->addOption(
'force',
'f',
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 {
$phoneNumber = $input->getArgument('phone');
$userId = $input->getArgument('account');
$userId = $input->getArgument('user');
$force = (bool)$input->getOption('force');
$user = $this->userManager->get($userId);
if (!$user instanceof IUser) {
$output->writeln('<error>Invalid account "' . $userId . '" provided</error>');
$output->writeln('<error>Invalid user "' . $userId . '" provided</error>');
return self::FAILURE;
}
$userId = $user->getUID();
$phoneNumberStandard = $this->phoneNumberUtil->convertToStandardFormat($phoneNumber);
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;
}
$phoneNumber = $phoneNumberStandard;

View File

@ -27,7 +27,7 @@ class FindPhoneNumber extends Base {
protected function configure(): void {
$this
->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(
'phone',
null,
@ -35,17 +35,17 @@ class FindPhoneNumber extends Base {
'Phone number to search for',
)
->addOption(
'account',
'user',
null,
InputOption::VALUE_REQUIRED,
'Account to get number(s) for',
'User to get number(s) for',
)
;
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$phoneNumber = (string)$input->getOption('phone');
$userId = (string)$input->getOption('account');
$userId = (string)$input->getOption('user');
if ($phoneNumber !== '') {
try {
@ -59,7 +59,7 @@ class FindPhoneNumber extends Base {
}
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;
}

View File

@ -34,7 +34,7 @@ class ImportPhoneNumbers extends Base {
protected function configure(): void {
$this
->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(
'reset',
null,
@ -45,7 +45,7 @@ class ImportPhoneNumbers extends Base {
'force',
'f',
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]);
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;
}
$row[0] = $phoneNumberStandard;
$user = $this->userManager->get($row[1]);
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;
}
$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\Output\OutputInterface;
class RemoveAccount extends Base {
class RemoveUser extends Base {
public function __construct(
private PhoneNumberMapper $mapper,
@ -25,18 +25,18 @@ class RemoveAccount extends Base {
#[\Override]
protected function configure(): void {
$this
->setName('talk:phone-number:remove-account')
->setDescription('Remove mapping entries by account')
->setName('talk:phone-number:remove-user')
->setDescription('Remove mapping entries by user')
->addArgument(
'account',
'user',
InputArgument::REQUIRED,
'Account to remove all mapping entries for',
'User to remove all mapping entries for',
)
;
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$userId = $input->getArgument('account');
$userId = $input->getArgument('user');
$this->mapper->deleteByUser($userId);
return self::SUCCESS;
}

View File

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