@@ -62,36 +62,36 @@ |
||
62 | 62 | $this->config->setAppValue(Application::APP_ID, 'xmpp_sender', $sender); |
63 | 63 | } |
64 | 64 | |
65 | - public function getPassword(): string { |
|
66 | - return $this->getOrFail('xmpp_password'); |
|
67 | - } |
|
68 | - |
|
69 | - public function setPassword(string $password) { |
|
70 | - $this->config->setAppValue(Application::APP_ID, 'xmpp_password', $password); |
|
71 | - } |
|
72 | - |
|
73 | - public function getServer(): string { |
|
74 | - return $this->getOrFail('xmpp_server'); |
|
75 | - } |
|
76 | - |
|
77 | - public function setServer(string $server) { |
|
78 | - $this->config->setAppValue(Application::APP_ID, 'xmpp_server', $server); |
|
79 | - } |
|
80 | - |
|
81 | - public function getUsername(): string { |
|
82 | - return $this->getOrFail('xmpp_username'); |
|
83 | - } |
|
84 | - |
|
85 | - public function setUsername(string $username) { |
|
86 | - $this->config->setAppValue(Application::APP_ID, 'xmpp_username', $username); |
|
87 | - } |
|
88 | - public function getMethod(): string { |
|
89 | - return $this->getOrFail('xmpp_method'); |
|
90 | - } |
|
91 | - |
|
92 | - public function setMethod(string $method) { |
|
93 | - $this->config->setAppValue(Application::APP_ID, 'xmpp_method', $method); |
|
94 | - } |
|
65 | + public function getPassword(): string { |
|
66 | + return $this->getOrFail('xmpp_password'); |
|
67 | + } |
|
68 | + |
|
69 | + public function setPassword(string $password) { |
|
70 | + $this->config->setAppValue(Application::APP_ID, 'xmpp_password', $password); |
|
71 | + } |
|
72 | + |
|
73 | + public function getServer(): string { |
|
74 | + return $this->getOrFail('xmpp_server'); |
|
75 | + } |
|
76 | + |
|
77 | + public function setServer(string $server) { |
|
78 | + $this->config->setAppValue(Application::APP_ID, 'xmpp_server', $server); |
|
79 | + } |
|
80 | + |
|
81 | + public function getUsername(): string { |
|
82 | + return $this->getOrFail('xmpp_username'); |
|
83 | + } |
|
84 | + |
|
85 | + public function setUsername(string $username) { |
|
86 | + $this->config->setAppValue(Application::APP_ID, 'xmpp_username', $username); |
|
87 | + } |
|
88 | + public function getMethod(): string { |
|
89 | + return $this->getOrFail('xmpp_method'); |
|
90 | + } |
|
91 | + |
|
92 | + public function setMethod(string $method) { |
|
93 | + $this->config->setAppValue(Application::APP_ID, 'xmpp_method', $method); |
|
94 | + } |
|
95 | 95 | |
96 | 96 | public function isComplete(): bool { |
97 | 97 | $set = $this->config->getAppKeys(Application::APP_ID); |
@@ -68,16 +68,16 @@ discard block |
||
68 | 68 | public function send(IUser $user, string $identifier, string $message) { |
69 | 69 | $this->logger->debug("sending xmpp message to $identifier, message: $message"); |
70 | 70 | |
71 | - $sender = $this->gatewayConfig->getSender(); |
|
72 | - $password = $this->gatewayConfig->getPassword(); |
|
73 | - $server = $this->gatewayConfig->getServer(); |
|
71 | + $sender = $this->gatewayConfig->getSender(); |
|
72 | + $password = $this->gatewayConfig->getPassword(); |
|
73 | + $server = $this->gatewayConfig->getServer(); |
|
74 | 74 | $method = $this->gatewayConfig->getMethod(); |
75 | 75 | $user = $this->gatewayConfig->getUsername(); |
76 | 76 | $url = $server.$identifier; |
77 | 77 | |
78 | - if ($method === "1") { |
|
78 | + if ($method === "1") { |
|
79 | 79 | $from = $user; |
80 | - } |
|
80 | + } |
|
81 | 81 | if ($method === "2") { |
82 | 82 | $from = $sender; |
83 | 83 | } |
@@ -85,15 +85,15 @@ discard block |
||
85 | 85 | |
86 | 86 | try { |
87 | 87 | $ch = curl_init(); |
88 | - curl_setopt($ch, CURLOPT_URL, $url ); |
|
89 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 ); |
|
90 | - curl_setopt($ch, CURLOPT_POST, 1 ); |
|
91 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $message ); |
|
92 | - curl_setopt($ch, CURLOPT_USERPWD, $from.":".$password ); |
|
93 | - curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/plain')); |
|
88 | + curl_setopt($ch, CURLOPT_URL, $url ); |
|
89 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 ); |
|
90 | + curl_setopt($ch, CURLOPT_POST, 1 ); |
|
91 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $message ); |
|
92 | + curl_setopt($ch, CURLOPT_USERPWD, $from.":".$password ); |
|
93 | + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/plain')); |
|
94 | 94 | $result = curl_exec($ch); |
95 | - curl_close($ch); |
|
96 | - $this->logger->debug("XMPP message to $identifier sent"); |
|
95 | + curl_close($ch); |
|
96 | + $this->logger->debug("XMPP message to $identifier sent"); |
|
97 | 97 | } catch (Exception $ex) { |
98 | 98 | throw new SmsTransmissionException(); |
99 | 99 | } |
@@ -85,12 +85,12 @@ |
||
85 | 85 | |
86 | 86 | try { |
87 | 87 | $ch = curl_init(); |
88 | - curl_setopt($ch, CURLOPT_URL, $url ); |
|
89 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 ); |
|
90 | - curl_setopt($ch, CURLOPT_POST, 1 ); |
|
91 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $message ); |
|
92 | - curl_setopt($ch, CURLOPT_USERPWD, $from.":".$password ); |
|
93 | - curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/plain')); |
|
88 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
89 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
90 | + curl_setopt($ch, CURLOPT_POST, 1); |
|
91 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $message); |
|
92 | + curl_setopt($ch, CURLOPT_USERPWD, $from.":".$password); |
|
93 | + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/plain')); |
|
94 | 94 | $result = curl_exec($ch); |
95 | 95 | curl_close($ch); |
96 | 96 | $this->logger->debug("XMPP message to $identifier sent"); |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | /** @var TelegramGateway */ |
41 | 41 | private $telegramGateway; |
42 | 42 | |
43 | - /** @var XMPPGateway */ |
|
44 | - private $xmppGateway; |
|
43 | + /** @var XMPPGateway */ |
|
44 | + private $xmppGateway; |
|
45 | 45 | |
46 | 46 | public function __construct(SignalGateway $signalGateway, |
47 | 47 | SMSGateway $smsGateway, |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $this->signalGateway = $signalGateway; |
51 | 51 | $this->smsGateway = $smsGateway; |
52 | 52 | $this->telegramGateway = $telegramGateway; |
53 | - $this->xmppGateway = $xmppGateway; |
|
53 | + $this->xmppGateway = $xmppGateway; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | public function getGateway(string $name): IGateway { |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | return $this->smsGateway; |
62 | 62 | case 'telegram': |
63 | 63 | return $this->telegramGateway; |
64 | - case 'xmpp': |
|
65 | - return $this->xmppGateway; |
|
64 | + case 'xmpp': |
|
65 | + return $this->xmppGateway; |
|
66 | 66 | default: |
67 | 67 | throw new Exception("Invalid gateway <$name>"); |
68 | 68 | } |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | /** @var TelegramGateway */ |
45 | 45 | private $telegramGateway; |
46 | 46 | |
47 | - /** @var XMPPGateway */ |
|
48 | - private $xmppGateway; |
|
47 | + /** @var XMPPGateway */ |
|
48 | + private $xmppGateway; |
|
49 | 49 | |
50 | 50 | public function __construct(SignalGateway $signalGateway, |
51 | 51 | SMSGateway $smsGateway, |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | case 'telegram': |
80 | 80 | $gateway = $this->telegramGateway; |
81 | 81 | break; |
82 | - case 'xmpp': |
|
83 | - $gateway = $this->xmppGateway; |
|
84 | - break; |
|
82 | + case 'xmpp': |
|
83 | + $gateway = $this->xmppGateway; |
|
84 | + break; |
|
85 | 85 | default: |
86 | 86 | $output->writeln("<error>Invalid gateway $gatewayName</error>"); |
87 | 87 | return 1; |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | /** @var TelegramGateway */ |
46 | 46 | private $telegramGateway; |
47 | 47 | |
48 | - /** @var XMPPGateway */ |
|
49 | - private $xmppGateway; |
|
48 | + /** @var XMPPGateway */ |
|
49 | + private $xmppGateway; |
|
50 | 50 | |
51 | 51 | /** @var IUserManager */ |
52 | 52 | private $userManager; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | public function __construct(SignalGateway $signalGateway, |
55 | 55 | SMSGateway $smsGateway, |
56 | 56 | TelegramGateway $telegramGateway, |
57 | - XMPPGateway $xmppGateway, |
|
57 | + XMPPGateway $xmppGateway, |
|
58 | 58 | IUserManager $userManager) { |
59 | 59 | parent::__construct('twofactorauth:gateway:test'); |
60 | 60 | $this->signalGateway = $signalGateway; |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | case 'telegram': |
103 | 103 | $gateway = $this->telegramGateway; |
104 | 104 | break; |
105 | - case 'xmpp': |
|
106 | - $gateway = $this->xmppGateway; |
|
107 | - break; |
|
105 | + case 'xmpp': |
|
106 | + $gateway = $this->xmppGateway; |
|
107 | + break; |
|
108 | 108 | default: |
109 | 109 | $output->writeln("<error>Invalid gateway $gatewayName</error>"); |
110 | 110 | return; |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | case 'telegram': |
101 | 101 | $this->configureTelegram($input, $output); |
102 | 102 | return 0; |
103 | - case 'xmpp': |
|
104 | - $this->configureXMPP($input, $output); |
|
105 | - return 0; |
|
103 | + case 'xmpp': |
|
104 | + $this->configureXMPP($input, $output); |
|
105 | + return 0; |
|
106 | 106 | default: |
107 | 107 | $output->writeln("<error>Invalid gateway $gatewayName</error>"); |
108 | 108 | return; |
@@ -439,64 +439,64 @@ discard block |
||
439 | 439 | $config->setBotToken($token); |
440 | 440 | } |
441 | 441 | |
442 | - private function configureXMPP(InputInterface $input, OutputInterface $output) { |
|
443 | - $helper = $this->getHelper('question'); |
|
442 | + private function configureXMPP(InputInterface $input, OutputInterface $output) { |
|
443 | + $helper = $this->getHelper('question'); |
|
444 | 444 | $sender = ''; |
445 | 445 | while (empty($sender) or substr_count($sender,'@') !== 1): |
446 | - $senderQuestion = new Question('Please enter your sender XMPP-JID: '); |
|
447 | - $sender = $helper->ask($input, $output, $senderQuestion); |
|
446 | + $senderQuestion = new Question('Please enter your sender XMPP-JID: '); |
|
447 | + $sender = $helper->ask($input, $output, $senderQuestion); |
|
448 | 448 | if (empty($sender)) { |
449 | - $output->writeln("XMPP-JID must not be empty!"); |
|
449 | + $output->writeln("XMPP-JID must not be empty!"); |
|
450 | 450 | } |
451 | 451 | elseif (substr_count($sender,'@') !== 1) { |
452 | - $output->writeln("XMPP-JID not valid!"); |
|
452 | + $output->writeln("XMPP-JID not valid!"); |
|
453 | 453 | } |
454 | 454 | else { |
455 | - $username = explode('@',$sender)[0]; |
|
455 | + $username = explode('@',$sender)[0]; |
|
456 | 456 | } |
457 | 457 | endwhile; |
458 | - $output->writeln("Using $sender as XMPP-JID.\nUsing $username as username."); |
|
458 | + $output->writeln("Using $sender as XMPP-JID.\nUsing $username as username."); |
|
459 | 459 | $password = ''; |
460 | 460 | while (empty($password)): |
461 | 461 | $passwordQuestion = new Question('Please enter your sender XMPP password: '); |
462 | - $password = $helper->ask($input, $output, $passwordQuestion); |
|
462 | + $password = $helper->ask($input, $output, $passwordQuestion); |
|
463 | 463 | if (empty($password)) { |
464 | - $output->writeln("Password must not be empty!"); |
|
465 | - } |
|
464 | + $output->writeln("Password must not be empty!"); |
|
465 | + } |
|
466 | 466 | endwhile; |
467 | - $output->writeln("Password accepted."); |
|
468 | - $server = ''; |
|
469 | - while (empty($server)): |
|
470 | - $serverQuestion = new Question('Please enter full path to access REST/HTTP API: '); |
|
471 | - $server = $helper->ask($input, $output, $serverQuestion); |
|
472 | - if (empty($server)) { |
|
473 | - $output->writeln("API path must not be empty!"); |
|
474 | - } |
|
475 | - endwhile; |
|
476 | - $output->writeln("Using $server as full URL to access REST/HTTP API."); |
|
477 | - $method = 0; |
|
478 | - while (intval($method) < 1 or intval($method) > 2): |
|
467 | + $output->writeln("Password accepted."); |
|
468 | + $server = ''; |
|
469 | + while (empty($server)): |
|
470 | + $serverQuestion = new Question('Please enter full path to access REST/HTTP API: '); |
|
471 | + $server = $helper->ask($input, $output, $serverQuestion); |
|
472 | + if (empty($server)) { |
|
473 | + $output->writeln("API path must not be empty!"); |
|
474 | + } |
|
475 | + endwhile; |
|
476 | + $output->writeln("Using $server as full URL to access REST/HTTP API."); |
|
477 | + $method = 0; |
|
478 | + while (intval($method) < 1 or intval($method) > 2): |
|
479 | 479 | echo "Please enter 1 or 2 for XMPP sending option:\n"; |
480 | 480 | echo "(1) prosody with mod_rest\n"; |
481 | 481 | echo "(2) prosody with mod_post_msg\n"; |
482 | - $methodQuestion = new Question('Your choice: '); |
|
483 | - $method = $helper->ask($input, $output, $methodQuestion); |
|
484 | - endwhile; |
|
485 | - if ($method === "1") { |
|
486 | - $output->writeln("Using prosody with mod_rest as XMPP sending option."); |
|
487 | - } |
|
488 | - elseif ($method === "2") { |
|
489 | - $output->writeln("Using prosody with mod_post_msg as XMPP sending option."); |
|
490 | - } |
|
491 | - $output->writeln("XMPP Admin Configuration finished."); |
|
482 | + $methodQuestion = new Question('Your choice: '); |
|
483 | + $method = $helper->ask($input, $output, $methodQuestion); |
|
484 | + endwhile; |
|
485 | + if ($method === "1") { |
|
486 | + $output->writeln("Using prosody with mod_rest as XMPP sending option."); |
|
487 | + } |
|
488 | + elseif ($method === "2") { |
|
489 | + $output->writeln("Using prosody with mod_post_msg as XMPP sending option."); |
|
490 | + } |
|
491 | + $output->writeln("XMPP Admin Configuration finished."); |
|
492 | 492 | |
493 | 493 | /** @var XMPPConfig $config */ |
494 | - $config = $this->xmppGateway->getConfig(); |
|
494 | + $config = $this->xmppGateway->getConfig(); |
|
495 | 495 | |
496 | - $config->setSender($sender); |
|
496 | + $config->setSender($sender); |
|
497 | 497 | $config->setPassword($password); |
498 | 498 | $config->setServer($server); |
499 | 499 | $config->setUsername($username); |
500 | 500 | $config->setMethod($method); |
501 | - } |
|
501 | + } |
|
502 | 502 | } |
@@ -442,17 +442,17 @@ |
||
442 | 442 | private function configureXMPP(InputInterface $input, OutputInterface $output) { |
443 | 443 | $helper = $this->getHelper('question'); |
444 | 444 | $sender = ''; |
445 | - while (empty($sender) or substr_count($sender,'@') !== 1): |
|
445 | + while (empty($sender) or substr_count($sender, '@') !== 1): |
|
446 | 446 | $senderQuestion = new Question('Please enter your sender XMPP-JID: '); |
447 | 447 | $sender = $helper->ask($input, $output, $senderQuestion); |
448 | 448 | if (empty($sender)) { |
449 | 449 | $output->writeln("XMPP-JID must not be empty!"); |
450 | 450 | } |
451 | - elseif (substr_count($sender,'@') !== 1) { |
|
451 | + elseif (substr_count($sender, '@') !== 1) { |
|
452 | 452 | $output->writeln("XMPP-JID not valid!"); |
453 | 453 | } |
454 | 454 | else { |
455 | - $username = explode('@',$sender)[0]; |
|
455 | + $username = explode('@', $sender)[ 0 ]; |
|
456 | 456 | } |
457 | 457 | endwhile; |
458 | 458 | $output->writeln("Using $sender as XMPP-JID.\nUsing $username as username."); |
@@ -447,11 +447,9 @@ discard block |
||
447 | 447 | $sender = $helper->ask($input, $output, $senderQuestion); |
448 | 448 | if (empty($sender)) { |
449 | 449 | $output->writeln("XMPP-JID must not be empty!"); |
450 | - } |
|
451 | - elseif (substr_count($sender,'@') !== 1) { |
|
450 | + } elseif (substr_count($sender,'@') !== 1) { |
|
452 | 451 | $output->writeln("XMPP-JID not valid!"); |
453 | - } |
|
454 | - else { |
|
452 | + } else { |
|
455 | 453 | $username = explode('@',$sender)[0]; |
456 | 454 | } |
457 | 455 | endwhile; |
@@ -484,8 +482,7 @@ discard block |
||
484 | 482 | endwhile; |
485 | 483 | if ($method === "1") { |
486 | 484 | $output->writeln("Using prosody with mod_rest as XMPP sending option."); |
487 | - } |
|
488 | - elseif ($method === "2") { |
|
485 | + } elseif ($method === "2") { |
|
489 | 486 | $output->writeln("Using prosody with mod_post_msg as XMPP sending option."); |
490 | 487 | } |
491 | 488 | $output->writeln("XMPP Admin Configuration finished."); |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | /** @var TelegramGateway */ |
43 | 43 | private $telegramGateway; |
44 | 44 | |
45 | - /** @var XMPPGateway */ |
|
46 | - private $xmppGateway; |
|
45 | + /** @var XMPPGateway */ |
|
46 | + private $xmppGateway; |
|
47 | 47 | |
48 | 48 | public function __construct(SignalGateway $signalGateway, |
49 | 49 | SMSGateway $smsGateway, |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | $output->writeln('SMS gateway: ' . ($smsConfigured ? 'configured' : 'not configured')); |
64 | 64 | $telegramConfigured = $this->telegramGateway->getConfig()->isComplete(); |
65 | 65 | $output->writeln('Telegram gateway: ' . ($telegramConfigured ? 'configured' : 'not configured')); |
66 | - $xmppConfigured = $this->xmppGateway->getConfig()->isComplete(); |
|
67 | - $output->writeln('XMPP gateway: ' . ($xmppConfigured ? 'configured' : 'not configured')); |
|
66 | + $xmppConfigured = $this->xmppGateway->getConfig()->isComplete(); |
|
67 | + $output->writeln('XMPP gateway: ' . ($xmppConfigured ? 'configured' : 'not configured')); |
|
68 | 68 | return 0; |
69 | 69 | } |
70 | 70 | } |
@@ -58,13 +58,13 @@ |
||
58 | 58 | |
59 | 59 | protected function execute(InputInterface $input, OutputInterface $output) { |
60 | 60 | $signalConfigured = $this->signalGateway->getConfig()->isComplete(); |
61 | - $output->writeln('Signal gateway: ' . ($signalConfigured ? 'configured' : 'not configured')); |
|
61 | + $output->writeln('Signal gateway: '.($signalConfigured ? 'configured' : 'not configured')); |
|
62 | 62 | $smsConfigured = $this->smsGateway->getConfig()->isComplete(); |
63 | - $output->writeln('SMS gateway: ' . ($smsConfigured ? 'configured' : 'not configured')); |
|
63 | + $output->writeln('SMS gateway: '.($smsConfigured ? 'configured' : 'not configured')); |
|
64 | 64 | $telegramConfigured = $this->telegramGateway->getConfig()->isComplete(); |
65 | - $output->writeln('Telegram gateway: ' . ($telegramConfigured ? 'configured' : 'not configured')); |
|
65 | + $output->writeln('Telegram gateway: '.($telegramConfigured ? 'configured' : 'not configured')); |
|
66 | 66 | $xmppConfigured = $this->xmppGateway->getConfig()->isComplete(); |
67 | - $output->writeln('XMPP gateway: ' . ($xmppConfigured ? 'configured' : 'not configured')); |
|
67 | + $output->writeln('XMPP gateway: '.($xmppConfigured ? 'configured' : 'not configured')); |
|
68 | 68 | return 0; |
69 | 69 | } |
70 | 70 | } |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | /** @var TelegramProvider */ |
38 | 38 | private $telegramProvider; |
39 | 39 | |
40 | - /** @var XMPPProvider */ |
|
41 | - private $xmppProvider; |
|
40 | + /** @var XMPPProvider */ |
|
41 | + private $xmppProvider; |
|
42 | 42 | |
43 | 43 | public function __construct(SignalProvider $signalProvider, |
44 | 44 | SmsProvider $smsProvider, |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $this->signalProvider = $signalProvider; |
48 | 48 | $this->smsProvider = $smsProvider; |
49 | 49 | $this->telegramProvider = $telegramProvider; |
50 | - $this->xmppProvider = $xmppProvider; |
|
50 | + $this->xmppProvider = $xmppProvider; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | case 'telegram': |
61 | 61 | return $this->telegramProvider; |
62 | 62 | case 'xmpp': |
63 | - return $this->xmppProvider; |
|
63 | + return $this->xmppProvider; |
|
64 | 64 | default: |
65 | 65 | throw new InvalidSmsProviderException(); |
66 | 66 | } |