trypost/database/factories/WebhookLogFactory.php
Paulo Castellano 91a1d5ca1e
Slim webhook log broadcasts to fix Reverb payload-too-large (#329)
* Stop broadcasting webhook payloads so Reverb does not reject live log updates.

The Echo event only needs list metadata; Inertia reloads the full log after the status lands.

* Type webhook Echo payloads separately and cover delivered, failed, and pending broadcasts.

The show page still receives payload and body over HTTP; Echo only carries list metadata.
2026-09-04 10:04:07 -03:00

58 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace Database\Factories;
use App\Enums\Webhook\EventType;
use App\Models\Webhook;
use App\Models\WebhookLog;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<WebhookLog>
*/
class WebhookLogFactory extends Factory
{
protected $model = WebhookLog::class;
/**
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'webhook_id' => Webhook::factory(),
'event_type' => EventType::PostPublished->value,
'payload' => [
'type' => EventType::PostPublished->value,
'data' => [],
],
'response_status' => 200,
'response_body' => 'OK',
'delivered_at' => now(),
'attempts' => 1,
];
}
public function failed(): static
{
return $this->state(fn (array $attributes): array => [
'response_status' => 500,
'response_body' => 'Internal Server Error',
'delivered_at' => null,
'failed_at' => now(),
]);
}
public function pending(): static
{
return $this->state(fn (array $attributes): array => [
'response_status' => null,
'response_body' => null,
'delivered_at' => null,
'failed_at' => null,
'attempts' => 1,
]);
}
}