Skip to content

Commit

Permalink
change how webhook are sent to include the event name
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaultjunin committed Jan 8, 2025
1 parent fae7ce2 commit 21b92a6
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions app/Jobs/ProcessWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace App\Jobs;

use App\Models\WebhookConfiguration;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
Expand All @@ -16,14 +18,23 @@ class ProcessWebhook implements ShouldQueue

public function __construct(
private WebhookConfiguration $webhookConfiguration,
private string $eventName,
private array $data
) {}
private string $eventName,
private array $data
)
{
}

public function handle(): void
{
try {
Http::post($this->webhookConfiguration->endpoint, $this->data)->throw();
$client = new Client();
$client->post($this->webhookConfiguration->endpoint, [
"json" => $this->data,
"headers" => [
"User-Agent" => "pelican/panel",
"X-Webhook-Event" => $this->eventName,
]
]);
$successful = now();
} catch (\Exception) {
$successful = null;
Expand Down

0 comments on commit 21b92a6

Please sign in to comment.