Skip to content

Commit

Permalink
Merge branch '6.4' into 7.0
Browse files Browse the repository at this point in the history
* 6.4:
  fix test
  fix test
  [SecurityBundle] Fix failing tests
  fix tests
  [DependencyInjection] fix unable to make lazy service from readonly class
  [Dotenv] Specify envKey while loading variables with the dotenv:dump command
  [Mailer][Postmark][Webhook] Accept different date formats
  • Loading branch information
xabbuh committed Feb 9, 2024
2 parents 2f7e69a + 13d6d3f commit 435531b
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 10 deletions.
9 changes: 8 additions & 1 deletion RemoteEvent/PostmarkPayloadConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ public function convert(array $payload): AbstractMailerEvent
'SpamComplaint' => $payload['BouncedAt'],
default => throw new ParseException(sprintf('Unsupported event "%s".', $payload['RecordType'])),
};
if (!$date = \DateTimeImmutable::createFromFormat('Y-m-d\TH:i:sT', $payloadDate)) {

$date = \DateTimeImmutable::createFromFormat(\DateTimeInterface::ATOM, $payloadDate)
// microseconds, 6 digits
?: \DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.uP', $payloadDate)
// microseconds, 7 digits
?: \DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.u?P', $payloadDate);

if (!$date) {
throw new ParseException(sprintf('Invalid date "%s".', $payloadDate));
}
$event->setDate($date);
Expand Down
2 changes: 1 addition & 1 deletion Tests/Webhook/Fixtures/bounce.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"Details": "Test bounce details",
"Email": "john@example.com",
"From": "sender@example.com",
"BouncedAt": "2022-09-02T14:29:19Z",
"BouncedAt": "2022-09-02T14:29:19.1234567Z",
"DumpAvailable": true,
"Inactive": true,
"CanActivate": true,
Expand Down
2 changes: 1 addition & 1 deletion Tests/Webhook/Fixtures/bounce.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
$wh->setTags(['Test']);
$wh->setMetadata(['example' => 'value', 'example_2' => 'value']);
$wh->setReason('The server was unable to deliver your message (ex: unknown user, mailbox not found).');
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:sT', '2022-09-02T14:29:19Z'));
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.uP', '2022-09-02T14:29:19.123456Z'));

return $wh;
2 changes: 1 addition & 1 deletion Tests/Webhook/Fixtures/delivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
$wh->setTags(['welcome-email']);
$wh->setMetadata(['example' => 'value', 'example_2' => 'value']);
$wh->setReason('');
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:sT', '2022-09-02T11:49:27Z'));
$wh->setDate(\DateTimeImmutable::createFromFormat(\DateTimeInterface::ATOM, '2022-09-02T11:49:27Z'));

return $wh;
2 changes: 1 addition & 1 deletion Tests/Webhook/Fixtures/link_click.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
$wh->setRecipientEmail('john@example.com');
$wh->setTags(['welcome-email']);
$wh->setMetadata(['example' => 'value', 'example_2' => 'value']);
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:sT', '2022-09-02T14:31:09Z'));
$wh->setDate(\DateTimeImmutable::createFromFormat(\DateTimeInterface::ATOM, '2022-09-02T14:31:09Z'));

return $wh;
2 changes: 1 addition & 1 deletion Tests/Webhook/Fixtures/open.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
$wh->setRecipientEmail('john@example.com');
$wh->setTags(['welcome-email']);
$wh->setMetadata(['example' => 'value', 'example_2' => 'value']);
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:sT', '2022-09-02T14:30:47Z'));
$wh->setDate(\DateTimeImmutable::createFromFormat(\DateTimeInterface::ATOM, '2022-09-02T14:30:47Z'));

return $wh;
2 changes: 1 addition & 1 deletion Tests/Webhook/Fixtures/spam_complaint.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"Details": "Test spam complaint details",
"Email": "john@example.com",
"From": "sender@example.com",
"BouncedAt": "2022-09-02T14:29:57Z",
"BouncedAt": "2022-09-02T14:29:57.123456Z",
"DumpAvailable": true,
"Inactive": true,
"CanActivate": false,
Expand Down
3 changes: 1 addition & 2 deletions Tests/Webhook/Fixtures/spam_complaint.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
$wh->setRecipientEmail('john@example.com');
$wh->setTags(['Test']);
$wh->setMetadata(['example' => 'value', 'example_2' => 'value']);
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:sT', '2022-09-02T14:29:57Z'));

$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.uP', '2022-09-02T14:29:57.123456Z'));
return $wh;
2 changes: 1 addition & 1 deletion Tests/Webhook/Fixtures/subscription_change.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
$wh->setRecipientEmail('john@example.com');
$wh->setTags(['welcome-email']);
$wh->setMetadata(['example' => 'value', 'example_2' => 'value']);
$wh->setDate(\DateTimeImmutable::createFromFormat('Y-m-d\TH:i:sT', '2022-09-02T14:32:30Z'));
$wh->setDate(\DateTimeImmutable::createFromFormat(\DateTimeInterface::ATOM, '2022-09-02T14:32:30Z'));

return $wh;

0 comments on commit 435531b

Please sign in to comment.