Skip to content

Commit

Permalink
Merge pull request #11912 from beetofly/4.4
Browse files Browse the repository at this point in the history
Fixes #11888 for mailjet puts only : in lead_donotcontact.comment
  • Loading branch information
escopecz committed Jul 24, 2023
2 parents 0d57617 + fb9aa1c commit 768de0e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
Expand Up @@ -103,9 +103,15 @@ public function processCallbackRequest(Request $request)
continue;
}

if ('bounce' === $event['event'] || 'blocked' === $event['event']) {
$reason = $event['error_related_to'].': '.$event['error'];
if (('bounce' === $event['event']) || ('blocked' === $event['event'])) {
$type = DoNotContact::BOUNCED;
if ('blocked' === $event['event']) {
$reason = 'BLOCKED: '.$event['error_related_to'].': '.$event['error'];
} elseif (false === $event['hard_bounce']) {
$reason = 'SOFT: '.$event['error_related_to'].': '.$event['error'].': '.$event['comment'];
} else {
$reason = 'HARD: '.$event['error_related_to'].': '.$event['error'];
}
} elseif ('spam' === $event['event']) {
$reason = 'User reported email as spam, source: '.$event['source'];
$type = DoNotContact::UNSUBSCRIBED;
Expand Down
15 changes: 8 additions & 7 deletions app/bundles/EmailBundle/Tests/Transport/MailjetTransportTest.php
Expand Up @@ -34,17 +34,17 @@ public function testWebhookPayloadIsProcessed()
->method('addFailureByHashId')
->withConsecutive(
[$this->equalTo('1'), 'User unsubscribed', DoNotContact::UNSUBSCRIBED],
[$this->equalTo('2'), 'blocked: blocked', DoNotContact::BOUNCED],
[$this->equalTo('2'), 'BLOCKED: blocked: blocked', DoNotContact::BOUNCED],
[$this->equalTo('3'), 'User reported email as spam, source: spam button', DoNotContact::UNSUBSCRIBED],
[$this->equalTo('4'), 'bounced: bounced', DoNotContact::BOUNCED],
[$this->equalTo('5'), 'bounced: bounced', DoNotContact::BOUNCED]
[$this->equalTo('4'), 'SOFT: bounced: bounced: text of mailjet', DoNotContact::BOUNCED],
[$this->equalTo('5'), 'HARD: bounced: bounced', DoNotContact::BOUNCED]
);

$this->transportCallback->expects($this->once())
->method('addFailureByAddress')
->with(
'bounce2@test.com',
'bounced: bounce without hash',
'HARD: bounced: bounce without hash',
DoNotContact::BOUNCED
);

Expand Down Expand Up @@ -119,9 +119,10 @@ private function getRequestWithPayload()
"CustomID": "4-bounce@test.com",
"Payload": "",
"blocked": "",
"hard_bounce": "",
"hard_bounce": false,
"error_related_to": "bounced",
"error": "bounced"
"error": "bounced",
"comment": "text of mailjet"
},
{
"event": "bounce",
Expand All @@ -134,7 +135,7 @@ private function getRequestWithPayload()
"CustomID": "5-bounce3@test-test.com",
"Payload": "",
"blocked": "",
"hard_bounce": "",
"hard_bounce": true,
"error_related_to": "bounced",
"error": "bounced"
},
Expand Down

0 comments on commit 768de0e

Please sign in to comment.