UPSTREAM BASELINE: nextcloud/spreed v22.0.12 (без изменений)
Type checking / changes (push) Has been cancelled
Type checking / test (push) Has been cancelled
Type checking / typescript-summary (push) Has been cancelled
Node tests / changes (push) Has been cancelled
Node tests / test (push) Has been cancelled
Node tests / test-summary (push) Has been cancelled
Type checking / changes (push) Has been cancelled
Type checking / test (push) Has been cancelled
Type checking / typescript-summary (push) Has been cancelled
Node tests / changes (push) Has been cancelled
Node tests / test (push) Has been cancelled
Node tests / test-summary (push) Has been cancelled
Источник: https://github.com/nextcloud/spreed/archive/refs/tags/v22.0.12.tar.gz С этого коммита ветка официального Nextcloud Talk отрезана (решение владельца 2026-07-06). Все дальнейшие изменения — только наши; версии релизов: 22.0.12-f7.N.
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace OCA\Talk\Command\PhoneNumber;
|
||||
|
||||
use OC\Core\Command\Base;
|
||||
use OCA\Talk\Model\PhoneNumber;
|
||||
use OCA\Talk\Model\PhoneNumberMapper;
|
||||
use OCA\Talk\Service\PhoneNumberValidation;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class AddPhoneNumber extends Base {
|
||||
|
||||
public function __construct(
|
||||
private IUserManager $userManager,
|
||||
private PhoneNumberValidation $phoneNumberValidation,
|
||||
private PhoneNumberMapper $mapper,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
protected function configure(): void {
|
||||
$this
|
||||
->setName('talk:phone-number:add')
|
||||
->setDescription('Add a mapping entry to map a phone number to an user')
|
||||
->addArgument(
|
||||
'phone',
|
||||
InputArgument::REQUIRED,
|
||||
'Phone number that will be called',
|
||||
)
|
||||
->addArgument(
|
||||
'user',
|
||||
InputArgument::REQUIRED,
|
||||
'User to be added to the conversation',
|
||||
)
|
||||
->addOption(
|
||||
'force',
|
||||
'f',
|
||||
InputOption::VALUE_NONE,
|
||||
'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('user');
|
||||
$force = (bool)$input->getOption('force');
|
||||
|
||||
$user = $this->userManager->get($userId);
|
||||
if (!$user instanceof IUser) {
|
||||
$output->writeln('<error>Invalid user "' . $userId . '" provided</error>');
|
||||
return self::FAILURE;
|
||||
}
|
||||
$userId = $user->getUID();
|
||||
|
||||
try {
|
||||
$phoneNumber = $this->phoneNumberValidation->validateNumber($phoneNumber);
|
||||
} catch (\InvalidArgumentException) {
|
||||
$output->writeln('<error>Not a valid phone number ' . $phoneNumber . '. The format is invalid.</error>');
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
try {
|
||||
$entry = $this->mapper->findByPhoneNumber($phoneNumber);
|
||||
} catch (DoesNotExistException) {
|
||||
$entry = null;
|
||||
}
|
||||
|
||||
if ($entry !== null) {
|
||||
$oldActor = $entry->getActorId();
|
||||
if (!$force) {
|
||||
$output->writeln('<error>Phone number is already assigned to ' . $oldActor . '</error>');
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$entry->setActorId($userId);
|
||||
$this->mapper->update($entry);
|
||||
|
||||
$output->writeln('<info>Phone number ' . $entry->getPhoneNumber() . ' is now assigned to ' . $entry->getActorId() . '</info>');
|
||||
$output->writeln('Was assigned to ' . $oldActor . ' before');
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
$entry = new PhoneNumber();
|
||||
$entry->setPhoneNumber($phoneNumber);
|
||||
$entry->setActorId($userId);
|
||||
$this->mapper->insert($entry);
|
||||
|
||||
$output->writeln('<info>Phone number ' . $entry->getPhoneNumber() . ' is now assigned to ' . $entry->getActorId() . '</info>');
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace OCA\Talk\Command\PhoneNumber;
|
||||
|
||||
use OC\Core\Command\Base;
|
||||
use OCA\Talk\Model\PhoneNumberMapper;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class FindPhoneNumber extends Base {
|
||||
|
||||
public function __construct(
|
||||
private PhoneNumberMapper $mapper,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
protected function configure(): void {
|
||||
$this
|
||||
->setName('talk:phone-number:find')
|
||||
->setDescription('Find a phone number or the phone number of an user')
|
||||
->addOption(
|
||||
'phone',
|
||||
null,
|
||||
InputOption::VALUE_REQUIRED,
|
||||
'Phone number to search for',
|
||||
)
|
||||
->addOption(
|
||||
'user',
|
||||
null,
|
||||
InputOption::VALUE_REQUIRED,
|
||||
'User to get number(s) for',
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int {
|
||||
$phoneNumber = (string)$input->getOption('phone');
|
||||
$userId = (string)$input->getOption('user');
|
||||
|
||||
if ($phoneNumber !== '') {
|
||||
try {
|
||||
$entry = $this->mapper->findByPhoneNumber($phoneNumber);
|
||||
} catch (DoesNotExistException) {
|
||||
$output->writeln('<error>Phone number ' . $phoneNumber . ' could not be found</error>');
|
||||
return self::FAILURE;
|
||||
}
|
||||
$output->writeln('Phone number ' . $entry->getPhoneNumber() . ' is assigned to ' . $entry->getActorId());
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
if ($userId === '') {
|
||||
$output->writeln('<error>Neither phone number nor user provided</error>');
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$entries = $this->mapper->findByUser($userId);
|
||||
if (empty($entries)) {
|
||||
$output->writeln('<error>No phone number found for ' . $userId . '</error>');
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
if (count($entries) === 1) {
|
||||
$entry = array_pop($entries);
|
||||
$output->writeln($entry->getActorId() . ' has phone number ' . $entry->getPhoneNumber() . ' assigned');
|
||||
} else {
|
||||
$output->writeln($userId . ' has the following phone numbers assigned:');
|
||||
foreach ($entries as $entry) {
|
||||
$output->writeln(' - ' . $entry->getPhoneNumber());
|
||||
}
|
||||
}
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace OCA\Talk\Command\PhoneNumber;
|
||||
|
||||
use OC\Core\Command\Base;
|
||||
use OCA\Talk\Model\PhoneNumber;
|
||||
use OCA\Talk\Model\PhoneNumberMapper;
|
||||
use OCA\Talk\Service\PhoneNumberValidation;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class ImportPhoneNumbers extends Base {
|
||||
|
||||
public function __construct(
|
||||
private IUserManager $userManager,
|
||||
private PhoneNumberValidation $phoneNumberValidation,
|
||||
private PhoneNumberMapper $mapper,
|
||||
private IDBConnection $db,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
protected function configure(): void {
|
||||
$this
|
||||
->setName('talk:phone-number:import')
|
||||
->setDescription('Import a CSV list (format: "number","user") for SIP dial-in')
|
||||
->addOption(
|
||||
'reset',
|
||||
null,
|
||||
InputOption::VALUE_NONE,
|
||||
'Delete all phone numbers before importing',
|
||||
)
|
||||
->addOption(
|
||||
'force',
|
||||
'f',
|
||||
InputOption::VALUE_NONE,
|
||||
'Force the numbers to the given user even when they are assigned already',
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int {
|
||||
$reset = (bool)$input->getOption('reset');
|
||||
$force = (bool)$input->getOption('force');
|
||||
|
||||
$this->db->beginTransaction();
|
||||
if ($reset) {
|
||||
$this->db->truncateTable('talk_phone_numbers', false);
|
||||
$force = false;
|
||||
}
|
||||
|
||||
$handle = $this->getResourceFromStdin();
|
||||
if ($handle === false) {
|
||||
$output->writeln('<error>Invalid StdIn provided</error>');
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$map = [];
|
||||
while ($row = fgetcsv($handle, escape: '')) {
|
||||
if (count($row) !== 2 || $row[0] === '' || $row[1] === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$row[0] = $this->phoneNumberValidation->validateNumber($row[0]);
|
||||
} catch (\InvalidArgumentException) {
|
||||
$output->writeln('<error>Not a valid phone number ' . $row[0] . '. The format is invalid.</error>');
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$user = $this->userManager->get($row[1]);
|
||||
if (!$user instanceof IUser) {
|
||||
$output->writeln('<error>Invalid user "' . $row[1] . '" provided</error>');
|
||||
return self::FAILURE;
|
||||
}
|
||||
$row[1] = $user->getUID();
|
||||
|
||||
$map[$row[0]] = $row[1];
|
||||
}
|
||||
|
||||
$entries = $this->mapper->findByPhoneNumbers(array_keys($map));
|
||||
|
||||
if (!$force && !empty($entries)) {
|
||||
$output->writeln('<error>Phone number already assigned:</error>');
|
||||
foreach ($entries as $entry) {
|
||||
$output->writeln(' - ' . $entry->getPhoneNumber());
|
||||
}
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
foreach ($map as $phoneNumber => $userId) {
|
||||
$entry = new PhoneNumber();
|
||||
$entry->setPhoneNumber($phoneNumber);
|
||||
$entry->setActorId($userId);
|
||||
$this->mapper->insert($entry);
|
||||
|
||||
$output->writeln('<info>Phone number ' . $entry->getPhoneNumber() . ' is now assigned to ' . $entry->getActorId() . '</info>');
|
||||
}
|
||||
|
||||
$this->db->commit();
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the resource from stdin ("talk:phone-numbers:import < file.csv")
|
||||
* @return resource|false
|
||||
*/
|
||||
protected function getResourceFromStdin() {
|
||||
return fopen('php://stdin', 'rb');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace OCA\Talk\Command\PhoneNumber;
|
||||
|
||||
use OC\Core\Command\Base;
|
||||
use OCA\Talk\Model\PhoneNumberMapper;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class RemovePhoneNumber extends Base {
|
||||
|
||||
public function __construct(
|
||||
private PhoneNumberMapper $mapper,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
protected function configure(): void {
|
||||
$this
|
||||
->setName('talk:phone-number:remove')
|
||||
->setDescription('Remove a mapping entry by phone number')
|
||||
->addArgument(
|
||||
'phone',
|
||||
InputArgument::REQUIRED,
|
||||
'Phone number to remove the mapping entry for',
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int {
|
||||
$phoneNumber = $input->getArgument('phone');
|
||||
$this->mapper->deleteByPhoneNumber($phoneNumber);
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace OCA\Talk\Command\PhoneNumber;
|
||||
|
||||
use OC\Core\Command\Base;
|
||||
use OCA\Talk\Model\PhoneNumberMapper;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class RemoveUser extends Base {
|
||||
|
||||
public function __construct(
|
||||
private PhoneNumberMapper $mapper,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
protected function configure(): void {
|
||||
$this
|
||||
->setName('talk:phone-number:remove-user')
|
||||
->setDescription('Remove mapping entries by user')
|
||||
->addArgument(
|
||||
'user',
|
||||
InputArgument::REQUIRED,
|
||||
'User to remove all mapping entries for',
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int {
|
||||
$userId = $input->getArgument('user');
|
||||
$this->mapper->deleteByUser($userId);
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user