64 lines
1.5 KiB
PHP
64 lines
1.5 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace App\Events\Webhook;
|
||
|
|
|
||
|
|
use App\Models\WebhookLog;
|
||
|
|
use Illuminate\Broadcasting\PrivateChannel;
|
||
|
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||
|
|
use Illuminate\Foundation\Events\Dispatchable;
|
||
|
|
use Illuminate\Queue\SerializesModels;
|
||
|
|
|
||
|
|
class LogUpdated implements ShouldBroadcast
|
||
|
|
{
|
||
|
|
use Dispatchable, SerializesModels;
|
||
|
|
|
||
|
|
public int $tries = 3;
|
||
|
|
|
||
|
|
/** @var array<int, int> */
|
||
|
|
public array $backoff = [5, 10];
|
||
|
|
|
||
|
|
public function __construct(
|
||
|
|
public WebhookLog $log,
|
||
|
|
) {}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @return array<int, PrivateChannel>
|
||
|
|
*/
|
||
|
|
public function broadcastOn(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
new PrivateChannel("webhook.{$this->log->webhook_id}.logs"),
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
public function broadcastAs(): string
|
||
|
|
{
|
||
|
|
return 'webhook.log.updated';
|
||
|
|
}
|
||
|
|
|
||
|
|
public function broadcastQueue(): string
|
||
|
|
{
|
||
|
|
return 'broadcasts';
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @return array<string, mixed>
|
||
|
|
*/
|
||
|
|
public function broadcastWith(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'id' => $this->log->id,
|
||
|
|
'event_type' => $this->log->event_type,
|
||
|
|
'payload' => $this->log->payload,
|
||
|
|
'response_status' => $this->log->response_status,
|
||
|
|
'response_body' => $this->log->response_body,
|
||
|
|
'delivered_at' => $this->log->delivered_at?->toIso8601String(),
|
||
|
|
'failed_at' => $this->log->failed_at?->toIso8601String(),
|
||
|
|
'attempts' => $this->log->attempts,
|
||
|
|
'created_at' => $this->log->created_at->toIso8601String(),
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|