Skip to content

Commit

Permalink
BUGFIX: prevent duplicate sms sending
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvainraye committed Nov 22, 2021
1 parent da8579a commit d684dad
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Model/SmsCampaignSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public function send()
ContactInformationFieldsProvider::CONTACT_INFORMATION_SCOPE_PHONE
);

$toSent = [];
foreach ($iterator as $item) {
$entity = array_shift($item);

Expand All @@ -145,6 +146,10 @@ public function send()
}
$to = array_filter(array_unique(array_merge($toFromFields, $toFromEntity)));

if (in_array($to, $toSent)) {
continue;
}

try {
$manager->beginTransaction();

Expand All @@ -155,9 +160,10 @@ public function send()
$to
);

$statisticsRecord = $this->statisticsConnector->getStatisticsRecord($this->smsCampaign, $entity);
$toSent[] = $to;

// Mark marketing list item as contacted
$statisticsRecord = $this->statisticsConnector->getStatisticsRecord($this->smsCampaign, $entity);
$statisticsRecord->getMarketingListItem()->contact();

$manager->flush($statisticsRecord);
Expand Down

0 comments on commit d684dad

Please sign in to comment.