Fix bug when duplicated newsletter uses the source's coupon

On duplication, the sensitive data of the coupon were
inherited from the source

[MAILPOET-4678]
This commit is contained in:
Sam Najian
2023-01-20 17:15:39 +01:00
committed by Aschepikov
parent 6164a92b9f
commit 7ced42a494
4 changed files with 100 additions and 1 deletions

View File

@@ -74,6 +74,9 @@ class NewsletterSaveController {
/** @var Scheduler */
private $scheduler;
/*** @var NewsletterCoupon */
private $newsletterCoupon;
public function __construct(
AuthorizedEmailsController $authorizedEmailsController,
Emoji $emoji,
@@ -89,7 +92,8 @@ class NewsletterSaveController {
Security $security,
WPFunctions $wp,
ApiDataSanitizer $dataSanitizer,
Scheduler $scheduler
Scheduler $scheduler,
NewsletterCoupon $newsletterCoupon
) {
$this->authorizedEmailsController = $authorizedEmailsController;
$this->emoji = $emoji;
@@ -106,6 +110,7 @@ class NewsletterSaveController {
$this->wp = $wp;
$this->dataSanitizer = $dataSanitizer;
$this->scheduler = $scheduler;
$this->newsletterCoupon = $newsletterCoupon;
}
public function save(array $data = []): NewsletterEntity {
@@ -182,6 +187,7 @@ class NewsletterSaveController {
// reset sent at date
$duplicate->setSentAt(null);
$duplicate = $this->newsletterCoupon->cleanupSensitiveData($duplicate);
$this->newslettersRepository->persist($duplicate);
$this->newslettersRepository->flush();