mirror of
https://github.com/bitinflow/expose.git
synced 2026-03-13 13:35:54 +00:00
32 lines
895 B
PHP
32 lines
895 B
PHP
<?php
|
|
|
|
namespace App\Client\Callbacks;
|
|
|
|
use App\Server\Connections\ControlConnection;
|
|
use Clue\React\Buzz\Browser;
|
|
|
|
class WebHookConnectionCallback
|
|
{
|
|
/** @var Browser */
|
|
protected $browser;
|
|
|
|
public function __construct(Browser $browser)
|
|
{
|
|
$this->browser = $browser;
|
|
}
|
|
|
|
public function handle(ControlConnection $connection)
|
|
{
|
|
$this->browser->post(config('expose.admin.connection_callbacks.webhook.url'), [
|
|
'Content-Type' => 'application/json',
|
|
'Accept' => 'application/json',
|
|
'X-Signature' => $this->generateWebhookSigningSecret($connection),
|
|
], json_encode($connection->toArray()));
|
|
}
|
|
|
|
protected function generateWebhookSigningSecret(ControlConnection $connection)
|
|
{
|
|
return hash_hmac('sha256', $connection->client_id, config('expose.admin.connection_callbacks.webhook.secret'));
|
|
}
|
|
}
|