Refactor notification event payloads and listener naming
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user