8000 [Mailer][Postmark][Webhook] Accept different date formats · symfony/symfony@aa9e308 · GitHub
[go: up one dir, main page]

Skip to content

Commit aa9e308

Browse files
committed
[Mailer][Postmark][Webhook] Accept different date formats
Postmark webhooks sometimes use "plain" ISO 6801 format, sometimes including 7 digits microseconds. As the PHP parameter only allows for 6 digits neither would parse without fallbacks. Fixes #53788
1 parent 7cda7b4 commit aa9e308

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Symfony/Component/Mailer/Bridge/Postmark/RemoteEvent/PostmarkPayloadConverter.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,14 @@ public function convert(array $payload): AbstractMailerEvent
4747
'SpamComplaint' => $payload['BouncedAt'],
4848
default => throw new ParseException(sprintf('Unsupported event "%s".', $payload['RecordType'])),
4949
};
50-
if (!$date = \DateTimeImmutable::createFromFormat('Y-m-d\TH:i:sT', $payloadDate)) {
50+
51+
$date = \DateTimeImmutable::createFromFormat(\DateTimeInterface::ATOM, $payloadDate)
52+
// microseconds, 6 digits
53+
?: \DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.uP', $payloadDate)
54+
// microseconds, 7 digits
55+
?: \DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.u?P', $payloadDate);
56+
57+
if (!$date) {
5158
throw new ParseException(sprintf('Invalid date "%s".', $payloadDate));
5259
}
5360
$event->setDate($date);

0 commit comments

Comments
 (0)
0