Skip to content

Commit

Permalink
Fixing Import custom email template functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
shinde-rahul committed Aug 25, 2023
1 parent 32bdaae commit 8af114b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
4 changes: 1 addition & 3 deletions app/bundles/EmailBundle/Helper/MailHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1328,13 +1328,11 @@ public function setEmail(Email $email, $allowBcc = true, $slots = [], $assetAtta
$this->setPlainText($plainText);
}

$BCcontent = $email->getContent();
$customHtml = $email->getCustomHtml();
// Process emails created by Mautic v1
if (empty($customHtml) && !empty($BCcontent)) {
if (empty($customHtml)) {
$template = $email->getTemplate();
if (empty($slots)) {
$template = $email->getTemplate();
$slots = $this->factory->getTheme($template)->getSlots('email');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,4 +387,35 @@ public function testEmailDetailsPageShouldNotHavePendingCount(): void

$this->assertCount(0, $pendingCountQuery);
}

public function testSendEmailForImportCustomEmailTemplate(): void
{
$email = new Email();
$email->setName('Test Email C');
$email->setSubject('Test Email C Subject');
$email->setTemplate('blank');
$email->setEmailType('template');

$contact = new Lead();
$contact->setEmail('john@doe.email');

$this->em->persist($email);
$this->em->persist($contact);
$this->em->flush();

// Create the member now.
$payload = [
'action' => 'lead:getEmailTemplate',
'template' => $email->getId(),
];

$this->client->request('GET', '/s/ajax', $payload, [], $this->createAjaxHeaders());
$clientResponse = $this->client->getResponse();
$response = json_decode($clientResponse->getContent(), true);

$this->assertSame(1, $response['success']);
$this->assertNotEmpty($response['subject']);
$this->assertEquals($email->getSubject(), $response['subject']);
$this->assertNotEmpty($response['body']);
}
}

0 comments on commit 8af114b

Please sign in to comment.