Пример #1
0
 /**
  * Trigger point actions for page hits.
  *
  * @param Events\PageHitEvent $event
  */
 public function onPageHit(Events\PageHitEvent $event)
 {
     $hit = $event->getHit();
     $redirect = $hit->getRedirect();
     if ($redirect && ($email = $hit->getEmail())) {
         // Check for an email stat
         $clickthrough = $event->getClickthroughData();
         if (isset($clickthrough['stat'])) {
             $stat = $this->emailModel->getEmailStatus($clickthrough['stat']);
         }
         if (empty($stat)) {
             if ($lead = $hit->getLead()) {
                 // Try searching by email and lead IDs
                 $stats = $this->emailModel->getEmailStati($hit->getSourceId(), $lead->getId());
                 if (count($stats)) {
                     $stat = $stats[0];
                 }
             }
         }
         if (!empty($stat)) {
             // Check to see if it has been marked as opened
             if (!$stat->isRead()) {
                 // Mark it as read
                 $this->emailModel->hitEmail($stat, $this->request);
             }
         }
     }
 }
Пример #2
0
 /**
  * Process if an email is resent.
  *
  * @param Events\QueueEmailEvent $event
  */
 public function onEmailResend(Events\QueueEmailEvent $event)
 {
     $message = $event->getMessage();
     if (isset($message->leadIdHash)) {
         $stat = $this->emailModel->getEmailStatus($message->leadIdHash);
         if ($stat !== null) {
             $stat->upRetryCount();
             $retries = $stat->getRetryCount();
             if (true || $retries > 3) {
                 //tried too many times so just fail
                 $reason = $this->translator->trans('mautic.email.dnc.retries', ['%subject%' => EmojiHelper::toShort($message->getSubject())]);
                 $this->emailModel->setDoNotContact($stat, $reason);
             } else {
                 //set it to try again
                 $event->tryAgain();
             }
             $this->em->persist($stat);
             $this->em->flush();
         }
     }
 }