Refactor notification event payloads and listener naming
linter / quality (pull_request) Successful in 1m17s
tests / ci (8.4) (pull_request) Failing after 1m35s

This commit is contained in:
2026-04-25 21:54:42 +00:00
parent 20f89952e7
commit 61505ace23
16 changed files with 286 additions and 115 deletions
@@ -28,7 +28,7 @@ class DeliverNotificationAction implements ShouldQueue
public function __construct(
public int $notificationActionId,
public TicketStatusChangedPayload $payload,
public NotificationEvent $event,
public ?int $notificationDeliveryLogId,
) {}
@@ -60,7 +60,7 @@ class DeliverNotificationAction implements ShouldQueue
if ($notificationAction->channel === NotificationChannel::Discord) {
$discordMessage = app(RenderDiscordMessageTemplate::class)->handle(
$notificationAction->message_template,
$this->payload,
$this->event,
);
$validationError = $this->discordMessageValidationError($discordMessage);
@@ -245,7 +245,7 @@ class DeliverNotificationAction implements ShouldQueue
'attempt_count' => 0,
'channel' => $notificationAction->channel,
'delivery_status' => NotificationDeliveryStatus::Pending,
'event_type' => $this->payload->eventType,
'event_type' => $this->event->payload()->eventType(),
'notification_action_id' => $notificationAction->id,
'payload_metadata' => $this->payloadMetadata(),
]);
@@ -334,7 +334,7 @@ class DeliverNotificationAction implements ShouldQueue
->asJson()
->connectTimeout(5)
->timeout(10)
->post($notificationAction->delivery_url, $this->payload->toArray());
->post($notificationAction->delivery_url, $this->event->payload()->toArray());
}
private function hasAttemptsRemaining(int $attemptCount): bool
@@ -398,14 +398,11 @@ class DeliverNotificationAction implements ShouldQueue
}
/**
* @return array{project_key: string, ticket_key: string}
* @return array<string, scalar|null>
*/
private function payloadMetadata(): array
{
return [
'project_key' => $this->payload->projectKey,
'ticket_key' => $this->payload->ticketKey,
];
return $this->event->payload()->deliveryMetadata();
}
private function excerpt(?string $value): ?string