From 5e03167dd7466ba4887a4a73d7c66927b824d0b2 Mon Sep 17 00:00:00 2001 From: aarohiprasad Date: Tue, 27 Feb 2024 23:02:05 +0530 Subject: [PATCH] removed email bounce destination and added test case --- EventSubscriber/CallbackSubscriber.php | 2 +- .../CallbackSubscriberTest.php | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/EventSubscriber/CallbackSubscriber.php b/EventSubscriber/CallbackSubscriber.php index fdc0743..cbc2f55 100644 --- a/EventSubscriber/CallbackSubscriber.php +++ b/EventSubscriber/CallbackSubscriber.php @@ -58,7 +58,7 @@ public function processCallbackRequest(TransportWebhookEvent $event): void $type = $messageEvent['type'] ?? null; $bounceClass = $messageEvent['bounce_class'] ?? null; - if ('bounce' === $type && !in_array((int) $bounceClass, [10, 30, 50, 51, 52, 53, 54, 90])) { + if ('bounce' === $type && !in_array((int) $bounceClass, [10, 30, 50, 51, 52, 53, 54, 90]) || ('out_of_band' === $type && (int) $bounceClass === 60)) { // Only parse hard bounces // https://support.sparkpost.com/customer/portal/articles/1929896-bounce-classification-codes continue; diff --git a/Tests/Functional/EventSubscriber/CallbackSubscriberTest.php b/Tests/Functional/EventSubscriber/CallbackSubscriberTest.php index f426233..4bfea3d 100644 --- a/Tests/Functional/EventSubscriber/CallbackSubscriberTest.php +++ b/Tests/Functional/EventSubscriber/CallbackSubscriberTest.php @@ -198,4 +198,36 @@ private function getCommentAndReason(string $type): array ], }; } + + /** + * For the message with 'type': 'out of band' and 'bounce class': 60 should never be called transportCallback. + */ + public function testProcessCallbackRequestWhenSoftBounce(): void + { + $payload = <<sparkpostTransport->processCallbackRequest($request); + $this->transportCallback->expects($this->never()) + ->method($this->anything()); + } }