@@ -72,24 +72,24 @@ discard block |
||
72 | 72 | $client = $this->clientService->newClient(); |
73 | 73 | // determine type of gateway |
74 | 74 | $response = $client->post( |
75 | - $this->config->getUrl() . '/api/v1/rpc', |
|
75 | + $this->config->getUrl().'/api/v1/rpc', |
|
76 | 76 | [ |
77 | 77 | 'http_errors' => false, |
78 | 78 | 'json' => [ |
79 | 79 | 'jsonrpc' => '2.0', |
80 | 80 | 'method' => 'version', |
81 | - 'id' => 'version_' . $this->timeFactory->getTime(), |
|
81 | + 'id' => 'version_'.$this->timeFactory->getTime(), |
|
82 | 82 | ], |
83 | 83 | ]); |
84 | 84 | if ($response->getStatusCode() === 200 || $response->getStatusCode() === 201) { |
85 | 85 | // native signal-cli JSON RPC. The 201 "created" is probably a bug. |
86 | 86 | $response = $response = $client->post( |
87 | - $this->config->getUrl() . '/api/v1/rpc', |
|
87 | + $this->config->getUrl().'/api/v1/rpc', |
|
88 | 88 | [ |
89 | 89 | 'json' => [ |
90 | 90 | 'jsonrpc' => '2.0', |
91 | 91 | 'method' => 'send', |
92 | - 'id' => 'code_' . $this->timeFactory->getTime(), |
|
92 | + 'id' => 'code_'.$this->timeFactory->getTime(), |
|
93 | 93 | 'params' => [ |
94 | 94 | 'recipient' => $identifier, |
95 | 95 | 'message' => $message, |
@@ -100,12 +100,12 @@ discard block |
||
100 | 100 | $body = $response->getBody(); |
101 | 101 | $json = json_decode($body, true); |
102 | 102 | $statusCode = $response->getStatusCode(); |
103 | - if ($statusCode < 200 || $statusCode >= 300 || is_null($json) || !is_array($json) || ($json['jsonrpc'] ?? null) != '2.0' || !isset($json['result']['timestamp'])) { |
|
103 | + if ($statusCode < 200 || $statusCode >= 300 || is_null($json) || !is_array($json) || ($json[ 'jsonrpc' ] ?? null) != '2.0' || !isset($json[ 'result' ][ 'timestamp' ])) { |
|
104 | 104 | throw new SmsTransmissionException("error reported by Signal gateway, status=$statusCode, body=$body}"); |
105 | 105 | } |
106 | 106 | } else { |
107 | 107 | $response = $client->get( |
108 | - $this->config->getUrl() . '/v1/about', |
|
108 | + $this->config->getUrl().'/v1/about', |
|
109 | 109 | [ |
110 | 110 | 'http_errors' => false, |
111 | 111 | ], |
@@ -117,10 +117,10 @@ discard block |
||
117 | 117 | // https://bbernhard.github.io/signal-cli-rest-api/ |
118 | 118 | $body = $response->getBody(); |
119 | 119 | $json = json_decode($body, true); |
120 | - $versions = $json['versions'] || []; |
|
120 | + $versions = $json[ 'versions' ] || [ ]; |
|
121 | 121 | if (is_array($versions) && in_array('v2', $versions)) { |
122 | 122 | $response = $client->post( |
123 | - $this->config->getUrl() . '/v2/send', |
|
123 | + $this->config->getUrl().'/v2/send', |
|
124 | 124 | [ |
125 | 125 | 'json' => [ |
126 | 126 | 'recipients' => $identifier, |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | ); |
132 | 132 | } else { |
133 | 133 | $response = $client->post( |
134 | - $this->config->getUrl() . '/v1/send/' . $identifier, |
|
134 | + $this->config->getUrl().'/v1/send/'.$identifier, |
|
135 | 135 | [ |
136 | 136 | 'json' => [ 'message' => $message ], |
137 | 137 | ] |
@@ -140,13 +140,13 @@ discard block |
||
140 | 140 | $body = $response->getBody(); |
141 | 141 | $json = json_decode($body, true); |
142 | 142 | $statusCode = $response->getStatusCode(); |
143 | - if ($statusCode !== 201 || is_null($json) || !is_array($json) || (!isset($json['timestamps']) && !isset($json['timestamp']))) { |
|
143 | + if ($statusCode !== 201 || is_null($json) || !is_array($json) || (!isset($json[ 'timestamps' ]) && !isset($json[ 'timestamp' ]))) { |
|
144 | 144 | throw new SmsTransmissionException("error reported by Signal gateway, status=$statusCode, body=$body}"); |
145 | 145 | } |
146 | 146 | } else { |
147 | 147 | // Try old deprecated gateway https://gitlab.com/morph027/signal-web-gateway |
148 | 148 | $response = $client->post( |
149 | - $this->config->getUrl() . '/v1/send/' . $identifier, |
|
149 | + $this->config->getUrl().'/v1/send/'.$identifier, |
|
150 | 150 | [ |
151 | 151 | 'body' => [ |
152 | 152 | 'to' => $identifier, |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $json = json_decode($body, true); |
160 | 160 | $statusCode = $response->getStatusCode(); |
161 | 161 | |
162 | - if ($statusCode !== 200 || is_null($json) || !is_array($json) || !isset($json['success']) || $json['success'] !== true) { |
|
162 | + if ($statusCode !== 200 || is_null($json) || !is_array($json) || !isset($json[ 'success' ]) || $json[ 'success' ] !== true) { |
|
163 | 163 | throw new SmsTransmissionException("error reported by Signal gateway, status=$statusCode, body=$body}"); |
164 | 164 | } |
165 | 165 | } |