Skip to content

Commit 1cefd9d

Browse files
committed
After review 0
1 parent d37ecc7 commit 1cefd9d

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

src/Domain/Messaging/MessageHandler/CampaignProcessorMessageHandler.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,11 @@ private function handleEmailSending(mixed $campaign, Subscriber $subscriber, Use
159159
$this->checkMessageSizeOrSuspendCampaign($campaign, $email, $subscriber->hasHtmlEmail());
160160
$this->updateUserMessageStatus($userMessage, UserMessageStatus::Sent);
161161
} catch (MessageSizeLimitExceededException $e) {
162+
// stop after the first message if size is exceeded
162163
$this->updateMessageStatus($campaign, MessageStatus::Suspended);
163164
$this->updateUserMessageStatus($userMessage, UserMessageStatus::Sent);
165+
166+
throw $e;
164167
} catch (Throwable $e) {
165168
$this->updateUserMessageStatus($userMessage, UserMessageStatus::NotSent);
166169
$this->logger->error($e->getMessage(), [

src/Domain/Messaging/Service/Manager/MessageDataManager.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace PhpList\Core\Domain\Messaging\Service\Manager;
66

7+
use Doctrine\ORM\EntityManagerInterface;
78
use PhpList\Core\Domain\Messaging\Model\Message;
89
use PhpList\Core\Domain\Messaging\Model\MessageData;
910
use PhpList\Core\Domain\Messaging\Repository\MessageDataRepository;
@@ -12,6 +13,7 @@ class MessageDataManager
1213
{
1314
public function __construct(
1415
private readonly MessageDataRepository $messageDataRepository,
16+
private readonly EntityManagerInterface $entityManager,
1517
) {
1618
}
1719

@@ -91,7 +93,7 @@ private function normalizeValueByName(string $name, mixed $value)
9193
'subject', 'campaigntitle' => is_string($value) ? strip_tags($value) : $value,
9294
'message' => is_string($value) ? $this->disableJavascript($value) : $value,
9395
'excludelist' => is_array($value) ? array_filter($value, fn ($val) => is_numeric($val)) : $value,
94-
'footer' => preg_replace('/<!--.*-->/', '', $value),
96+
'footer' => is_string($value) ? preg_replace('/<!--.*?-->/', '', $value) : $value,
9597
default => $value,
9698
};
9799
}
@@ -103,7 +105,7 @@ private function getOrCreateMessageDataEntity(Message $campaign, string $name)
103105
$entity = (new MessageData())
104106
->setId($campaign->getId())
105107
->setName($name);
106-
$this->messageDataRepository->persist($entity);
108+
$this->entityManager->persist($entity);
107109
}
108110

109111
return $entity;

src/Domain/Messaging/Service/MessageProcessingPreparator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private function replaceLinks(array $savedLinks, string $htmlText): string
9595
{
9696
foreach ($savedLinks as $linkTrack) {
9797
$originalUrl = $linkTrack->getUrl();
98-
$trackUrl = '/' . self::LINK_TRACK_ENDPOINT . '?id=' . $linkTrack->getId();
98+
$trackUrl = self::LINK_TRACK_ENDPOINT . '?id=' . $linkTrack->getId();
9999
$htmlText = str_replace('href="' . $originalUrl . '"', 'href="' . $trackUrl . '"', $htmlText);
100100
}
101101

tests/Unit/Domain/Messaging/Service/MessageProcessingPreparatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,11 @@ public function testProcessMessageLinksWithLinksExtracted(): void
206206

207207
$content->expects($this->once())
208208
->method('setText')
209-
->with($this->stringContains('/' . MessageProcessingPreparator::LINK_TRACK_ENDPOINT . '?id=1'));
209+
->with($this->stringContains( MessageProcessingPreparator::LINK_TRACK_ENDPOINT . '?id=1'));
210210

211211
$content->expects($this->once())
212212
->method('setFooter')
213-
->with($this->stringContains('/' . MessageProcessingPreparator::LINK_TRACK_ENDPOINT . '?id=1'));
213+
->with($this->stringContains(MessageProcessingPreparator::LINK_TRACK_ENDPOINT . '?id=1'));
214214

215215
$result = $this->preparator->processMessageLinks($message, $subscriber);
216216

0 commit comments

Comments
 (0)