Skip to content

Commit facea83

Browse files
authored
fix(webhooks): use correct messageId from MailGun (#44)
1 parent 7b2a07a commit facea83

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/Resources/LogResource.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ public static function table(Tables\Table $table): Tables\Table
130130
)
131131
->actions(
132132
Tables\Actions\ActionGroup::make(static::getTableActions())
133-
);
133+
)
134+
->paginationPageOptions([10, 25, 50, 100]);
134135
}
135136

136137
/**

src/Webhooks/Strategies/MailgunStrategy.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace MailCarrier\Webhooks\Strategies;
44

55
use Carbon\CarbonImmutable;
6+
use Illuminate\Support\Arr;
67
use Illuminate\Support\Facades\Config;
78
use MailCarrier\Webhooks\Dto\IncomingWebhook;
89
use MailCarrier\Webhooks\Dto\WebhookData;
@@ -75,13 +76,16 @@ public function extract(array $payload): WebhookData
7576
}
7677

7778
$eventData = $payload['event-data'];
79+
$messageId = Arr::get($eventData, 'message.headers.message-id');
80+
$event = Arr::get($eventData, 'event');
81+
$timestamp = Arr::get($eventData, 'timestamp');
7882

79-
if (!isset($eventData['id'], $eventData['event'], $eventData['timestamp'])) {
83+
if (empty($messageId) || empty($event) || empty($timestamp)) {
8084
throw new \InvalidArgumentException('Invalid Mailgun webhook payload: missing required fields');
8185
}
8286

8387
return new WebhookData(
84-
messageId: $eventData['id'],
88+
messageId: $messageId,
8589
eventName: $eventData['event'],
8690
date: CarbonImmutable::createFromTimestamp($eventData['timestamp'])
8791
);

0 commit comments

Comments
 (0)