Skip to content

Commit 5fc8637

Browse files
committed
Use MessagePrecacheDto
1 parent 3b9267f commit 5fc8637

File tree

8 files changed

+144
-154
lines changed

8 files changed

+144
-154
lines changed

config/parameters.yml.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,5 @@ parameters:
9696

9797
phplist.upload_images_dir: '%%env(PHPLIST_UPLOADIMAGES_DIR)%%'
9898
env(PHPLIST_UPLOADIMAGES_DIR): 'images'
99+
phplist.public_schema: '%%env(PUBLIC_SCHEMA)%%'
100+
env(PUBLIC_SCHEMA): 'http'

src/Domain/Analytics/Service/LinkTrackService.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
use PhpList\Core\Domain\Analytics\Exception\MissingMessageIdException;
99
use PhpList\Core\Domain\Analytics\Model\LinkTrack;
1010
use PhpList\Core\Domain\Analytics\Repository\LinkTrackRepository;
11-
use PhpList\Core\Domain\Messaging\Model\Message;
12-
use PhpList\Core\Domain\Messaging\Model\Message\MessageContent;
11+
use PhpList\Core\Domain\Messaging\Model\Dto\MessagePrecacheDto;
1312

1413
class LinkTrackService
1514
{
@@ -39,7 +38,7 @@ public function isExtractAndSaveLinksApplicable(): bool
3938
* @return LinkTrack[] The saved LinkTrack entities
4039
* @throws MissingMessageIdException
4140
*/
42-
public function extractAndSaveLinks(MessageContent $content, int $userId, ?int $messageId = null): array
41+
public function extractAndSaveLinks(MessagePrecacheDto $content, int $userId, ?int $messageId = null): array
4342
{
4443
if (!$this->isExtractAndSaveLinksApplicable()) {
4544
return [];
@@ -49,10 +48,10 @@ public function extractAndSaveLinks(MessageContent $content, int $userId, ?int $
4948
throw new MissingMessageIdException();
5049
}
5150

52-
$links = $this->extractLinksFromHtml($content->getText() ?? '');
51+
$links = $this->extractLinksFromHtml($content->content ?? '');
5352

54-
if ($content->getFooter() !== null) {
55-
$links = array_merge($links, $this->extractLinksFromHtml($content->getFooter()));
53+
if ($content->htmlFooter) {
54+
$links = array_merge($links, $this->extractLinksFromHtml($content->htmlFooter));
5655
}
5756

5857
$links = array_unique($links);

src/Domain/Identity/Repository/AdministratorRepository.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,18 @@ public function findOneByLoginCredentials(string $loginName, string $plainTextPa
5555
]
5656
);
5757
}
58+
59+
/** @return Administrator[] */
60+
public function getMessageRelatedAdmins(int $messageId): array
61+
{
62+
return $this->createQueryBuilder('a')
63+
->select('DISTINCT a')
64+
->join('a.ownedLists', 'ag')
65+
->join('ag.listMessages', 'lm')
66+
->join('lm.message', 'm')
67+
->where('m.id = :messageId')
68+
->setParameter('messageId', $messageId)
69+
->getQuery()
70+
->getResult();
71+
}
5872
}

src/Domain/Messaging/MessageHandler/CampaignProcessorMessageHandler.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use PhpList\Core\Domain\Messaging\Exception\MessageSizeLimitExceededException;
1010
use PhpList\Core\Domain\Messaging\Message\CampaignProcessorMessage;
1111
use PhpList\Core\Domain\Messaging\Message\SyncCampaignProcessorMessage;
12+
use PhpList\Core\Domain\Messaging\Model\Dto\MessagePrecacheDto;
1213
use PhpList\Core\Domain\Messaging\Model\Message;
1314
use PhpList\Core\Domain\Messaging\Model\Message\MessageStatus;
1415
use PhpList\Core\Domain\Messaging\Model\Message\UserMessageStatus;
@@ -75,8 +76,8 @@ public function __invoke(CampaignProcessorMessage|SyncCampaignProcessorMessage $
7576
return;
7677
}
7778

78-
$messageContent = $this->precacheService->getOrCacheBaseMessageContent($campaign);
79-
if (!$messageContent) {
79+
$messagePrecacheDto = $this->precacheService->getOrCacheBaseMessageContent($campaign);
80+
if (!$messagePrecacheDto) {
8081
$this->updateMessageStatus($campaign, MessageStatus::Suspended);
8182

8283
return;
@@ -111,7 +112,7 @@ public function __invoke(CampaignProcessorMessage|SyncCampaignProcessorMessage $
111112
continue;
112113
}
113114

114-
$this->handleEmailSending($campaign, $subscriber, $userMessage, $messageContent);
115+
$this->handleEmailSending($campaign, $subscriber, $userMessage, $messagePrecacheDto);
115116
}
116117

117118
if ($stoppedEarly && $this->requeueHandler->handle($campaign)) {
@@ -163,11 +164,11 @@ private function handleEmailSending(
163164
Message $campaign,
164165
Subscriber $subscriber,
165166
UserMessage $userMessage,
166-
Message\MessageContent $precachedContent,
167+
MessagePrecacheDto $precachedContent,
167168
): void {
168169
$processed = $this->messagePreparator->processMessageLinks($campaign->getId(), $precachedContent, $subscriber);
169-
$processed->setText($this->userPersonalizer->personalize($processed->getText(), $subscriber->getEmail()));
170-
$processed->setFooter($this->userPersonalizer->personalize($processed->getFooter(), $subscriber->getEmail()));
170+
$processed->textContent = $this->userPersonalizer->personalize($processed->textContent, $subscriber->getEmail());
171+
$processed->footer = $this->userPersonalizer->personalize($processed->footer, $subscriber->getEmail());
171172

172173
try {
173174
$email = $this->mailer->composeEmail($campaign, $subscriber, $processed);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PhpList\Core\Domain\Messaging\Model\Dto;
6+
7+
class MessagePrecacheDto
8+
{
9+
public string $replyToEmail;
10+
public string $replyToName;
11+
public string $fromName;
12+
public string $fromEmail;
13+
public string $to;
14+
public string $subject;
15+
public string $content;
16+
public string $textContent = '';
17+
public string $footer;
18+
public string $textFooter;
19+
public string $htmlFooter;
20+
public bool $htmlFormatted;
21+
public string $sendFormat;
22+
public ?string $template = '';
23+
public ?string $templateText = '';
24+
public ?int $templateId = 0;
25+
public string $htmlCharset= 'UTF-8';
26+
public string $textCharset= 'UTF-8';
27+
public bool $userSpecificUrl;
28+
public string $googleTrack;
29+
public array $adminAttributes = [];
30+
}

0 commit comments

Comments
 (0)