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:
  [TwigBridge] foundation 5 layout: use form_label_content block for checkbox and radio labels
  [TwigBridge] Fix compat with Twig v3.9
  [Cache] Sync the Redis proxies with upstream
  [Doctrine Messenger] Fix support for pgsql + pgbouncer.
  [Mailer] Simplify fix
  Do not produce notice/warning when consuming from multiple transports and explicitly listed queues
  [FrameworkBundle] Check if the _route attribute exists on the request
  [Scheduler] fix documentation link
  [PropertyAccess] Fixes getValue() on an unitialized object property on a lazy ghost
  [HttpClient] Make retry strategy work again
  AssetMapper: Remove 'auto-generated' info
  [Mailer] Fix signed emails breaking the profiler
  [Mailer] [Mailgun] Fix expecting payload without tags or user variables
  [Validator] Update Spanish (es) translations
  Fix fetching data in `W3CReferenceTest` on AppVeyor
  Fix SQS visibility_timeout type
  [VarDumper] Fix serialization of stubs with null or uninitialized values
  • Loading branch information
nicolas-grekas committed Feb 15, 2024
2 parents a866d1a + 8c01887 commit 96df0d3
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 6 deletions.
8 changes: 4 additions & 4 deletions RemoteEvent/MailgunPayloadConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public function convert(array $payload): AbstractMailerEvent
}
$event->setDate($date);
$event->setRecipientEmail($payload['recipient']);
$event->setMetadata($payload['user-variables']);
$event->setTags($payload['tags']);
$event->setMetadata($payload['user-variables'] ?? []);
$event->setTags($payload['tags'] ?? []);

return $event;
}
Expand All @@ -78,10 +78,10 @@ private function getReason(array $payload): string
if ('' !== ($payload['delivery-status']['description'] ?? '')) {
return $payload['delivery-status']['description'];
}
if ('' !== $payload['delivery-status']['message']) {
if ('' !== ($payload['delivery-status']['message'] ?? '')) {
return $payload['delivery-status']['message'];
}
if ('' !== $payload['reason']) {
if ('' !== ($payload['reason'] ?? '')) {
return $payload['reason'];
}

Expand Down
39 changes: 39 additions & 0 deletions Tests/Webhook/Fixtures/accepted.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"signature":{
"token": "885894756b6c371a377f5f9516d60a4db497ad27d4931ed215",
"timestamp": "1661621710",
"signature": "606307bb55b72686b1b2a2c8c37ae6e6ec89496592bac4a4eee5a346337d04a5"
},
"event-data":{
"event":"accepted",
"id":"4o7-z86dSkSI54c6IudeuA",
"timestamp":1707402341.91242,
"api-key-id":"##REDACTED##",
"envelope":{
"sender":"postmaster@mg.herehaveth.is",
"targets":"ben@##REDACTED##",
"transport":"smtp"
},
"flags":{
"is-authenticated":true,
"is-test-mode":false
},
"message":{
"headers":{
"message-id":"##REDACTED##",
"from":"\"Here, have this\" <hello@herehaveth.is>",
"to":"alice@example.com",
"subject":"Please verify your email address."
},
"size":2411
},
"storage":{
"key":"##REDACTED##",
"url":"https:\/\/storage-us-east4.api.mailgun.net\/v3\/domains\/##REDACTED##"
},
"method":"HTTP",
"log-level":"info",
"recipient":"alice@example.com",
"recipient-domain":"example.com"
}
}
9 changes: 9 additions & 0 deletions Tests/Webhook/Fixtures/accepted.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

use Symfony\Component\RemoteEvent\Event\Mailer\MailerDeliveryEvent;

$wh = new MailerDeliveryEvent(MailerDeliveryEvent::RECEIVED, '4o7-z86dSkSI54c6IudeuA', json_decode(file_get_contents(str_replace('.php', '.json', __FILE__)), true, flags: JSON_THROW_ON_ERROR)['event-data']);
$wh->setRecipientEmail('alice@example.com');
$wh->setDate(\DateTimeImmutable::createFromFormat('U.u', '1707402341.91242'));

return $wh;
2 changes: 0 additions & 2 deletions Webhook/MailgunRequestParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ protected function doParse(Request $request, #[\SensitiveParameter] string $secr
|| !isset($content['signature']['token'])
|| !isset($content['signature']['signature'])
|| !isset($content['event-data']['event'])
|| !isset($content['event-data']['tags'])
|| !isset($content['event-data']['user-variables'])
) {
throw new RejectWebhookException(406, 'Payload is malformed.');
}
Expand Down

0 comments on commit 96df0d3

Please sign in to comment.