1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @author Kim Syversen <[email protected]> |
7
|
|
|
* |
8
|
|
|
* Nextcloud - Two-factor Gateway |
9
|
|
|
* |
10
|
|
|
* This code is free software: you can redistribute it and/or modify |
11
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
12
|
|
|
* as published by the Free Software Foundation. |
13
|
|
|
* |
14
|
|
|
* This program is distributed in the hope that it will be useful, |
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17
|
|
|
* GNU Affero General Public License for more details. |
18
|
|
|
* |
19
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
20
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
21
|
|
|
* |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
namespace OCA\TwoFactorGateway\Service\Gateway\SMS\Provider; |
25
|
|
|
|
26
|
|
|
use Exception; |
27
|
|
|
use OCA\TwoFactorGateway\Exception\SmsTransmissionException; |
28
|
|
|
use OCP\Http\Client\IClient; |
29
|
|
|
use OCP\Http\Client\IClientService; |
30
|
|
|
use OCP\IConfig; |
31
|
|
|
|
32
|
|
|
class PuzzelSMS implements IProvider { |
33
|
|
|
|
34
|
|
|
const PROVIDER_ID = 'puzzelsms'; |
35
|
|
|
|
36
|
|
|
/** @var IClient */ |
37
|
|
|
private $client; |
38
|
|
|
|
39
|
|
|
/** @var PuzzelConfig */ |
|
|
|
|
40
|
|
|
private $config; |
41
|
|
|
|
42
|
|
|
public function __construct(IClientService $clientService, |
43
|
|
|
PuzzelSMSConfig $config) { |
44
|
|
|
$this->client = $clientService->newClient(); |
45
|
|
|
$this->config = $config; |
|
|
|
|
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param string $identifier |
50
|
|
|
* @param string $message |
51
|
|
|
* |
52
|
|
|
* @throws SmsTransmissionException |
53
|
|
|
*/ |
54
|
|
|
public function send(string $identifier, string $message) { |
55
|
|
|
$config = $this->getConfig(); |
56
|
|
|
|
57
|
|
|
try { |
58
|
|
|
$this->client->get( |
59
|
|
|
$config->getUrl(), |
|
|
|
|
60
|
|
|
[ |
61
|
|
|
'query' => [ |
62
|
|
|
'username' => $config->getUser(), |
|
|
|
|
63
|
|
|
'password' => $config->getPassword(), |
|
|
|
|
64
|
|
|
"message[0].recipient" => "+".$identifier, |
65
|
|
|
"message[0].content" => $message, |
66
|
|
|
'serviceId'=> $config->getServiceId(), |
|
|
|
|
67
|
|
|
], |
68
|
|
|
] |
69
|
|
|
); |
70
|
|
|
} catch (Exception $ex) { |
71
|
|
|
throw new SmsTransmissionException(); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return PuzzelConfig |
77
|
|
|
*/ |
78
|
|
|
public function getConfig(): IProviderConfig { |
79
|
|
|
return $this->config; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths