Implement generic webhook delivery

This commit is contained in:
Eric Peters
2026-04-24 18:13:50 +02:00
parent 71f07a8f7b
commit a1dc615958
4 changed files with 667 additions and 4 deletions
@@ -2,7 +2,10 @@
namespace App\Actions\Notifications;
use App\Enums\NotificationChannel;
use App\Enums\NotificationDeliveryStatus;
use App\Models\NotificationAction;
use App\Models\NotificationDeliveryLog;
class QueueTicketStatusChangedNotificationDeliveries
{
@@ -12,11 +15,28 @@ class QueueTicketStatusChangedNotificationDeliveries
->enabled()
->where('project_id', $event->payload->projectId)
->where('event_type', $event->payload->eventType->value)
->get(['id'])
->get(['channel', 'id'])
->each(function (NotificationAction $notificationAction) use ($event): void {
$notificationDeliveryLogId = null;
if ($notificationAction->channel === NotificationChannel::Webhook) {
$notificationDeliveryLogId = NotificationDeliveryLog::query()->create([
'attempt_count' => 0,
'channel' => $notificationAction->channel,
'delivery_status' => NotificationDeliveryStatus::Pending,
'event_type' => $event->payload->eventType,
'notification_action_id' => $notificationAction->id,
'payload_metadata' => [
'project_key' => $event->payload->projectKey,
'ticket_key' => $event->payload->ticketKey,
],
])->id;
}
DeliverNotificationAction::dispatch(
$notificationAction->id,
$event->payload,
notificationActionId: $notificationAction->id,
payload: $event->payload,
notificationDeliveryLogId: $notificationDeliveryLogId,
);
});
}