Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/Listeners/SendResourceLifecycleWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,18 @@ public function handle($event)
$apiEnvironment = session()->get('api_environment', $event->apiEnvironment ?? 'live');
$isSandbox = session()->get('is_sandbox', $event->isSandbox);

// Compute the event payload exactly once so the persisted ApiEvent record and the
// outbound webhook body are guaranteed to be identical. $event->getEventData() resolves
// the model live at handle time, whereas $event->data is a snapshot frozen at dispatch
// time; using each in a different place lets the DB record and the webhook diverge.
$payload = $event->getEventData();

// Prepare event
$eventData = [
'company_uuid' => $companyId,
'event' => $event->broadcastAs(),
'source' => $apiCredentialId ? 'api' : 'console',
'data' => $event->getEventData(),
'data' => $payload,
'method' => $event->requestMethod,
'description' => $this->getHumanReadableEventDescription($event),
];
Expand Down Expand Up @@ -100,7 +106,7 @@ public function handle($event)
'sent_at' => Carbon::now(),
])
->url($webhook->url)
->payload($event->data)
->payload($payload)
->useSecret($apiSecret)
->dispatch();
} catch (\Exception|\Aws\Sqs\Exception\SqsException $exception) {
Expand Down