/** * Convert emoji to short bytes. * * @param array|string $content * * @return array|string */ public function reverseTransform($content) { if (is_array($content)) { foreach ($content as &$convert) { $convert = $this->reverseTransform($convert); } } else { $content = EmojiHelper::toShort($content); } return $content; }
/** * @param $hash * @param $subject * @param $body */ public function saveCopy($hash, $subject, $body) { $db = $this->getEntityManager()->getConnection(); try { $body = EmojiHelper::toShort($body); $subject = EmojiHelper::toShort($subject); $db->insert(MAUTIC_TABLE_PREFIX . 'email_copies', ['id' => $hash, 'body' => $body, 'subject' => $subject, 'date_created' => (new \DateTime())->setTimezone(new \DateTimeZone('UTC'))->format('Y-m-d H:i:s')]); return true; } catch (\Exception $e) { error_log($e); return false; } }
/** * Process if an email is resent * * @param MauticEvents\EmailEvent $event */ public function onEmailResend(MauticEvents\EmailEvent $event) { $message = $event->getMessage(); if (isset($message->leadIdHash)) { $model = $this->factory->getModel('email'); $stat = $model->getEmailStatus($message->leadIdHash); if ($stat !== null) { $stat->upRetryCount(); $retries = $stat->getRetryCount(); if (true || $retries > 3) { //tried too many times so just fail $reason = $this->factory->getTranslator()->trans('mautic.email.dnc.retries', array("%subject%" => EmojiHelper::toShort($message->getSubject()))); $model->setDoNotContact($stat, $reason); } else { //set it to try again $event->tryAgain(); } $em = $this->factory->getEntityManager(); $em->persist($stat); $em->flush(); } } }
/** * @deprecated 1.2.3 - to be removed in 2.0 * * @param mixed $copy * * @return Stat */ public function setCopy($copy) { // Ensure it's clean of emoji $copy = EmojiHelper::toShort($copy); $this->copy = $copy; return $this; }
/** * 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(); } } }
/** * @param $content * * @return $this */ public function setContent($content) { // Ensure safe emoji $content = EmojiHelper::toShort($content); $this->isChanged('content', $content); $this->content = $content; return $this; }
/** * @param mixed $subject * * @return Copy */ public function setSubject($subject) { // Ensure it's clean of emoji $subject = EmojiHelper::toShort($subject); $this->subject = $subject; return $this; }