Skip to content

Commit

Permalink
Allow to use path option
Browse files Browse the repository at this point in the history
  • Loading branch information
makstech authored and sonologico committed Sep 29, 2022
1 parent 7449800 commit 50c9358
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/Pusher.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ public function make_request($channels, string $event, $data, array $params = []

$params = array_merge($signature, $query_params);
$query_string = self::array_implode('=', '&', $params);
$full_path = $path . "?" . $query_string;
$full_path = ltrim($path, '/') . "?" . $query_string;
return new Request('POST', $full_path, $headers, $post_value);
}

Expand Down Expand Up @@ -720,7 +720,7 @@ public function get(string $path, array $params = [], $associative = false)
'X-Pusher-Library' => 'pusher-http-php ' . self::$VERSION
];

$response = $this->client->get($path, [
$response = $this->client->get(ltrim($path, '/'), [
'query' => $signature,
'http_errors' => false,
'headers' => $headers,
Expand Down Expand Up @@ -771,7 +771,7 @@ public function post(string $path, $body, array $params = [])
];

try {
$response = $this->client->request('POST', $path, [
$response = $this->client->post(ltrim($path, '/'), [
'query' => $params_with_signature,
'body' => $body,
'http_errors' => false,
Expand Down Expand Up @@ -821,7 +821,7 @@ public function postAsync(string $path, $body, array $params = []): PromiseInter
'X-Pusher-Library' => 'pusher-http-php ' . self::$VERSION
];

return $this->client->requestAsync('POST', $path, [
return $this->client->postAsync(ltrim($path, '/'), [
'query' => $params_with_signature,
'body' => $body,
'http_errors' => false,
Expand Down Expand Up @@ -985,7 +985,7 @@ public function presence_auth(string $channel, string $socket_id, string $user_i
*/
public function webhook(array $headers, string $body): object
{
$this->ensure_valid_signature($headers, $body);
$this->verifySignature($headers, $body);

$decoded_events = [];
try {
Expand All @@ -995,7 +995,7 @@ public function webhook(array $headers, string $body): object
throw new PusherException('Data encoding error.');
}

foreach ($decoded_json->events as $key => $event) {
foreach ($decoded_json->events as $event) {
if (PusherCrypto::is_encrypted_channel($event->channel)) {
if (!is_null($this->crypto)) {
$decryptedEvent = $this->crypto->decrypt_event($event);
Expand All @@ -1007,7 +1007,6 @@ public function webhook(array $headers, string $body): object
$decoded_events[] = $decryptedEvent;
} else {
$this->log('Got an encrypted webhook event payload, but no master key specified. Ignoring.', null, LogLevel::WARNING);
continue;
}
} else {
$decoded_events[] = $event;
Expand Down

0 comments on commit 50c9358

Please sign in to comment.