Manage webhooks from the panel
Create one and see its secret once, send a test, change the secret, and read each delivery with what the other end answered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@ use App\Models\Application;
|
||||
use App\Models\ReviewComment;
|
||||
use App\Models\Revision;
|
||||
use App\Models\Webhook;
|
||||
use App\Models\WebhookDelivery;
|
||||
use App\Support\AdminContent;
|
||||
use App\Support\ContentTypes;
|
||||
use App\Support\SiteUrls;
|
||||
@@ -43,6 +44,38 @@ final class Webhooks
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A `ping`, to check the receiving end before anything real happens.
|
||||
*/
|
||||
public static function ping(Webhook $webhook): WebhookDelivery
|
||||
{
|
||||
$delivery = $webhook->deliveries()->create([
|
||||
'uuid' => (string) Str::uuid(),
|
||||
'event' => 'ping',
|
||||
'payload' => ['webhook' => $webhook->id, 'events' => $webhook->events],
|
||||
]);
|
||||
|
||||
DeliverWebhook::dispatch($delivery);
|
||||
|
||||
return $delivery->refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* One sent again, as a new delivery of the same event and payload.
|
||||
*/
|
||||
public static function redeliver(WebhookDelivery $delivery): WebhookDelivery
|
||||
{
|
||||
$again = $delivery->webhook->deliveries()->create([
|
||||
'uuid' => (string) Str::uuid(),
|
||||
'event' => $delivery->event,
|
||||
'payload' => $delivery->payload,
|
||||
]);
|
||||
|
||||
DeliverWebhook::dispatch($again);
|
||||
|
||||
return $again->refresh();
|
||||
}
|
||||
|
||||
public static function applicationReceived(Application $application): void
|
||||
{
|
||||
self::dispatch('application.received', [
|
||||
|
||||
Reference in New Issue
Block a user