Skip to content

Commit f3a6a9b

Browse files
committed
Do not retry to add other contact things if the contact has been deleted
1 parent 55e6195 commit f3a6a9b

5 files changed

Lines changed: 32 additions & 1 deletion

File tree

src/MessageHandler/Contact/ContactListsSubscriberHandler.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Sylius\Component\Core\Model\CustomerInterface;
1111
use Sylius\Component\Core\Repository\CustomerRepositoryInterface;
1212
use Symfony\Component\HttpKernel\Exception\HttpException;
13+
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
1314
use Webgriffe\SyliusActiveCampaignPlugin\Client\ActiveCampaignResourceClientInterface;
1415
use Webgriffe\SyliusActiveCampaignPlugin\Exception\ListSubscriptionStatusResolverExceptionInterface;
1516
use Webgriffe\SyliusActiveCampaignPlugin\Mapper\ContactListMapperInterface;
@@ -81,6 +82,15 @@ public function __invoke(ContactListsSubscriber $message): void
8182
$activeCampaignContactId,
8283
$listSubscriptionStatus,
8384
));
85+
} catch (NotFoundHttpException) {
86+
$this->logger->error(sprintf(
87+
'Contact with ActiveCampaign id "%s" (customer id "%s") was not found on ActiveCampaign while subscribing to list "%s". The contact may have been deleted on ActiveCampaign side.',
88+
$activeCampaignContactId,
89+
$customerId,
90+
$activeCampaignListId,
91+
));
92+
93+
return;
8494
} catch (HttpException $httpException) {
8595
if ($httpException->getStatusCode() !== 200) {
8696
throw $httpException;

src/MessageHandler/Contact/ContactTagsAdderHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function __invoke(ContactTagsAdder $message): void
6363
try {
6464
$this->activeCampaignContactTagClient->create($this->contactTagFactory->createNew($activeCampaignContactId, $activeCampaignTagId));
6565
} catch (NotFoundHttpException) {
66-
$this->logger->warning(sprintf(
66+
$this->logger->error(sprintf(
6767
'Contact with ActiveCampaign id "%s" (customer id "%s") was not found on ActiveCampaign while adding tag "%s". The contact may have been deleted on ActiveCampaign side.',
6868
$activeCampaignContactId,
6969
$customerId,

src/MessageHandler/Contact/ContactUpdateHandler.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Psr\Log\LoggerInterface;
1010
use Sylius\Component\Core\Model\CustomerInterface;
1111
use Sylius\Component\Core\Repository\CustomerRepositoryInterface;
12+
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
1213
use Webgriffe\SyliusActiveCampaignPlugin\Client\ActiveCampaignResourceClientInterface;
1314
use Webgriffe\SyliusActiveCampaignPlugin\Mapper\ContactMapperInterface;
1415
use Webgriffe\SyliusActiveCampaignPlugin\Message\Contact\ContactUpdate;
@@ -55,6 +56,12 @@ public function __invoke(ContactUpdate $message): void
5556

5657
try {
5758
$this->activeCampaignContactClient->update($message->getActiveCampaignId(), $this->contactMapper->mapFromCustomer($customer));
59+
} catch (NotFoundHttpException) {
60+
$this->logger?->error(sprintf(
61+
'Contact with ActiveCampaign id "%s" (customer id "%s") was not found on ActiveCampaign during update. The contact may have been deleted on ActiveCampaign side.',
62+
$message->getActiveCampaignId(),
63+
$customerId,
64+
));
5865
} catch (\Throwable $e) {
5966
$this->logger?->error($e->getMessage(), $e->getTrace());
6067

src/MessageHandler/EcommerceCustomer/EcommerceCustomerUpdateHandler.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Sylius\Component\Core\Model\ChannelInterface;
1212
use Sylius\Component\Core\Model\CustomerInterface;
1313
use Sylius\Component\Core\Repository\CustomerRepositoryInterface;
14+
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
1415
use Webgriffe\SyliusActiveCampaignPlugin\Client\ActiveCampaignResourceClientInterface;
1516
use Webgriffe\SyliusActiveCampaignPlugin\Mapper\EcommerceCustomerMapperInterface;
1617
use Webgriffe\SyliusActiveCampaignPlugin\Message\EcommerceCustomer\EcommerceCustomerUpdate;
@@ -73,6 +74,12 @@ public function __invoke(EcommerceCustomerUpdate $message): void
7374

7475
try {
7576
$this->activeCampaignClient->update($message->getActiveCampaignId(), $this->ecommerceCustomerMapper->mapFromCustomerAndChannel($customer, $channel));
77+
} catch (NotFoundHttpException) {
78+
$this->logger?->error(sprintf(
79+
'EcommerceCustomer with ActiveCampaign id "%s" (customer id "%s") was not found on ActiveCampaign during update. The resource may have been deleted on ActiveCampaign side.',
80+
$message->getActiveCampaignId(),
81+
$customerId,
82+
));
7683
} catch (\Throwable $e) {
7784
$this->logger?->error($e->getMessage(), $e->getTrace());
7885

src/MessageHandler/EcommerceOrder/EcommerceOrderUpdateHandler.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Psr\Log\LoggerInterface;
1010
use Sylius\Component\Core\Model\OrderInterface;
1111
use Sylius\Component\Core\Repository\OrderRepositoryInterface;
12+
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
1213
use Webgriffe\SyliusActiveCampaignPlugin\Client\ActiveCampaignResourceClientInterface;
1314
use Webgriffe\SyliusActiveCampaignPlugin\Mapper\EcommerceOrderMapperInterface;
1415
use Webgriffe\SyliusActiveCampaignPlugin\Message\EcommerceOrder\EcommerceOrderUpdate;
@@ -55,6 +56,12 @@ public function __invoke(EcommerceOrderUpdate $message): void
5556

5657
try {
5758
$this->activeCampaignEcommerceOrderClient->update($message->getActiveCampaignId(), $this->ecommerceOrderMapper->mapFromOrder($order, $message->isInRealTime()));
59+
} catch (NotFoundHttpException) {
60+
$this->logger?->error(sprintf(
61+
'EcommerceOrder with ActiveCampaign id "%s" (order id "%s") was not found on ActiveCampaign during update. The resource may have been deleted on ActiveCampaign side.',
62+
$message->getActiveCampaignId(),
63+
$orderId,
64+
));
5865
} catch (\Throwable $e) {
5966
$this->logger?->error($e->getMessage(), $e->getTrace());
6067

0 commit comments

Comments
 (0)