@@ -22,7 +22,7 @@ |
||
22 | 22 | ) { |
23 | 23 | } |
24 | 24 | |
25 | - #[\Override] |
|
25 | + #[\Override ] |
|
26 | 26 | public function getBody(): ITemplate { |
27 | 27 | $template = Server::get(ITemplateManager::class)->getTemplate('twofactor_gateway', 'personal_settings'); |
28 | 28 | $template->assign('gateway', $this->gateway); |
@@ -27,7 +27,7 @@ |
||
27 | 27 | } |
28 | 28 | |
29 | 29 | private function buildConfigKey(string $gatewayName, string $key): string { |
30 | - return $gatewayName . "_$key"; |
|
30 | + return $gatewayName."_$key"; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | private function getUserValue(IUser $user, string $gatewayName, string $key, string $default = ''): string { |
@@ -29,7 +29,7 @@ |
||
29 | 29 | * twofactorgateway?: TwoFactorGatewayCapabilities, |
30 | 30 | * } |
31 | 31 | */ |
32 | - #[Override] |
|
32 | + #[Override ] |
|
33 | 33 | public function getCapabilities(): array { |
34 | 34 | $capabilities = [ |
35 | 35 | 'features' => self::FEATURES, |
@@ -15,7 +15,7 @@ |
||
15 | 15 | use Symfony\Component\Console\Output\OutputInterface; |
16 | 16 | |
17 | 17 | interface IProvider { |
18 | - public const SCHEMA = []; |
|
18 | + public const SCHEMA = [ ]; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @param string $identifier |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | use Symfony\Component\Console\Input\InputOption; |
19 | 19 | use Symfony\Component\Console\Output\OutputInterface; |
20 | 20 | |
21 | -#[AsCommand(name: 'telegram:login', description: 'Login into Telegram using the Client API')] |
|
21 | +#[AsCommand(name: 'telegram:login', description: 'Login into Telegram using the Client API') ] |
|
22 | 22 | class Login extends Command { |
23 | 23 | |
24 | 24 | protected function configure(): void { |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | try { |
47 | 47 | $settings = (new Settings()) |
48 | 48 | ->setAppInfo($appInfo) |
49 | - ->setLogger((new Logger())->setExtra($sessionDirectory . '/MadelineProto.log')); |
|
49 | + ->setLogger((new Logger())->setExtra($sessionDirectory.'/MadelineProto.log')); |
|
50 | 50 | |
51 | 51 | $api = new API($sessionDirectory, $settings); |
52 | 52 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | return Command::SUCCESS; |
64 | 64 | } catch (\Throwable $e) { |
65 | - $output->writeln('<error>Error: ' . $e->getMessage() . '</error>'); |
|
65 | + $output->writeln('<error>Error: '.$e->getMessage().'</error>'); |
|
66 | 66 | return Command::FAILURE; |
67 | 67 | } |
68 | 68 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | use Symfony\Component\Console\Input\InputOption; |
19 | 19 | use Symfony\Component\Console\Output\OutputInterface; |
20 | 20 | |
21 | -#[AsCommand(name: 'telegram:send-message', description: 'Send a message via Telegram Client API')] |
|
21 | +#[AsCommand(name: 'telegram:send-message', description: 'Send a message via Telegram Client API') ] |
|
22 | 22 | class SendMessage extends Command { |
23 | 23 | |
24 | 24 | protected function configure(): void { |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | try { |
50 | 50 | $settings = (new Settings()) |
51 | - ->setLogger((new Logger())->setExtra($sessionDirectory . '/MadelineProto.log')); |
|
51 | + ->setLogger((new Logger())->setExtra($sessionDirectory.'/MadelineProto.log')); |
|
52 | 52 | |
53 | 53 | $message = $input->getOption('message'); |
54 | 54 | $peer = $input->getOption('to'); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | if (!str_starts_with($peer, '@')) { |
61 | 61 | try { |
62 | 62 | $result = $api->contacts->resolvePhone(phone: $peer); |
63 | - $peer = $result['peer']; |
|
63 | + $peer = $result[ 'peer' ]; |
|
64 | 64 | } catch (RPCErrorException $e) { |
65 | 65 | if ($e->getMessage() === 'PHONE_NOT_OCCUPIED') { |
66 | 66 | $output->writeln('<error>Error: The phone number is not associated with any Telegram account.</error>'); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | return Command::SUCCESS; |
83 | 83 | } catch (\Throwable $e) { |
84 | - $output->writeln('<error>Error: ' . $e->getMessage() . '</error>'); |
|
84 | + $output->writeln('<error>Error: '.$e->getMessage().'</error>'); |
|
85 | 85 | return Command::FAILURE; |
86 | 86 | } |
87 | 87 | } |
@@ -11,17 +11,17 @@ |
||
11 | 11 | |
12 | 12 | /** @extends AFactory<AProvider> */ |
13 | 13 | class Factory extends AFactory { |
14 | - #[\Override] |
|
14 | + #[\Override ] |
|
15 | 15 | protected function getPrefix(): string { |
16 | 16 | return 'OCA\\TwoFactorGateway\\Provider\\Channel\\'; |
17 | 17 | } |
18 | 18 | |
19 | - #[\Override] |
|
19 | + #[\Override ] |
|
20 | 20 | protected function getSuffix(): string { |
21 | 21 | return 'Provider'; |
22 | 22 | } |
23 | 23 | |
24 | - #[\Override] |
|
24 | + #[\Override ] |
|
25 | 25 | protected function getBaseClass(): string { |
26 | 26 | return AProvider::class; |
27 | 27 | } |
@@ -61,33 +61,33 @@ discard block |
||
61 | 61 | ); |
62 | 62 | } |
63 | 63 | |
64 | - #[\Override] |
|
65 | - public function send(string $identifier, string $message, array $extra = []): void { |
|
64 | + #[\Override ] |
|
65 | + public function send(string $identifier, string $message, array $extra = [ ]): void { |
|
66 | 66 | $this->logger->debug("sending telegram message to $identifier, message: $message"); |
67 | 67 | |
68 | 68 | $sessionFile = $this->getSessionDirectory(); |
69 | 69 | |
70 | - putenv('TELEGRAM_API_ID=' . $this->getApiId()); |
|
71 | - putenv('TELEGRAM_API_HASH=' . $this->getApiHash()); |
|
70 | + putenv('TELEGRAM_API_ID='.$this->getApiId()); |
|
71 | + putenv('TELEGRAM_API_HASH='.$this->getApiHash()); |
|
72 | 72 | |
73 | - $path = realpath(__DIR__ . '/ClientCli/Cli.php'); |
|
74 | - $cmd = 'php ' . escapeshellarg($path) . ' ' |
|
73 | + $path = realpath(__DIR__.'/ClientCli/Cli.php'); |
|
74 | + $cmd = 'php '.escapeshellarg($path).' ' |
|
75 | 75 | . 'telegram:send-message ' |
76 | - . '--session-directory ' . escapeshellarg($sessionFile) |
|
77 | - . ' --to ' . escapeshellarg($identifier) |
|
78 | - . ' --message ' . escapeshellarg($message); |
|
76 | + . '--session-directory '.escapeshellarg($sessionFile) |
|
77 | + . ' --to '.escapeshellarg($identifier) |
|
78 | + . ' --message '.escapeshellarg($message); |
|
79 | 79 | |
80 | 80 | exec($cmd, $output, $returnVar); |
81 | 81 | |
82 | 82 | if ($returnVar !== 0) { |
83 | - $this->logger->error('Error sending Telegram message', ['output' => $output, 'returnVar' => $returnVar]); |
|
83 | + $this->logger->error('Error sending Telegram message', [ 'output' => $output, 'returnVar' => $returnVar ]); |
|
84 | 84 | throw new MessageTransmissionException(); |
85 | 85 | } |
86 | 86 | |
87 | 87 | $this->logger->debug("telegram message to chat $identifier sent"); |
88 | 88 | } |
89 | 89 | |
90 | - #[\Override] |
|
90 | + #[\Override ] |
|
91 | 91 | public function cliConfigure(InputInterface $input, OutputInterface $output): int { |
92 | 92 | if (PHP_VERSION_ID < 80200) { |
93 | 93 | $output->writeln('The Telegram Client API provider requires PHP 8.2 or higher.'); |
@@ -103,15 +103,15 @@ discard block |
||
103 | 103 | $this->setApiId($apiId); |
104 | 104 | $this->setApiHash($apiHash); |
105 | 105 | |
106 | - putenv('TELEGRAM_API_ID=' . $apiId); |
|
107 | - putenv('TELEGRAM_API_HASH=' . $apiHash); |
|
106 | + putenv('TELEGRAM_API_ID='.$apiId); |
|
107 | + putenv('TELEGRAM_API_HASH='.$apiHash); |
|
108 | 108 | |
109 | 109 | $sessionFile = $this->getSessionDirectory(); |
110 | 110 | |
111 | - $path = realpath(__DIR__ . '/ClientCli/Cli.php'); |
|
112 | - $cmd = 'php ' . escapeshellarg($path) . ' ' |
|
111 | + $path = realpath(__DIR__.'/ClientCli/Cli.php'); |
|
112 | + $cmd = 'php '.escapeshellarg($path).' ' |
|
113 | 113 | . 'telegram:login ' |
114 | - . '--session-directory ' . escapeshellarg($sessionFile); |
|
114 | + . '--session-directory '.escapeshellarg($sessionFile); |
|
115 | 115 | |
116 | 116 | // This is only to create the client session files. |
117 | 117 | // The login will be made afterwards. |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | $output->writeln(''); |
124 | 124 | $output->writeln("<comment>$cmd</comment>"); |
125 | 125 | $output->writeln(''); |
126 | - $output->writeln('Make sure that the user to run the command is the same as the web server user: <info>' . $user['name'] . '</info>.'); |
|
126 | + $output->writeln('Make sure that the user to run the command is the same as the web server user: <info>'.$user[ 'name' ].'</info>.'); |
|
127 | 127 | $output->writeln(''); |
128 | 128 | $output->writeln('Follow the instructions in the command output.'); |
129 | 129 | return 0; |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | } |
139 | 139 | |
140 | 140 | $instanceId = $this->config->getSystemValueString('instanceid'); |
141 | - $appDataFolder = 'appdata_' . $instanceId; |
|
142 | - $dataDirectory = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data'); |
|
143 | - $fullPath = $dataDirectory . '/' . $appDataFolder . '/' . Application::APP_ID . '/session.madeline'; |
|
141 | + $appDataFolder = 'appdata_'.$instanceId; |
|
142 | + $dataDirectory = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data'); |
|
143 | + $fullPath = $dataDirectory.'/'.$appDataFolder.'/'.Application::APP_ID.'/session.madeline'; |
|
144 | 144 | |
145 | 145 | if (is_dir($fullPath) === false) { |
146 | 146 | $reflection = new \ReflectionClass($folder); |
@@ -50,7 +50,7 @@ |
||
50 | 50 | ); |
51 | 51 | } |
52 | 52 | |
53 | - #[\Override] |
|
53 | + #[\Override ] |
|
54 | 54 | public function send(string $identifier, string $message) { |
55 | 55 | $apiKey = $this->getApiKey(); |
56 | 56 | $username = $this->getUser(); |