Add meta when sending stats notifications
[MAILPOET-2333]
This commit is contained in:
committed by
Jack Kitterhing
parent
723cb368c4
commit
d40747e0ac
@ -7,6 +7,7 @@ use MailPoet\Config\Renderer;
|
||||
use MailPoet\Cron\Workers\SimpleWorker;
|
||||
use MailPoet\Features\FeaturesController;
|
||||
use MailPoet\Mailer\Mailer;
|
||||
use MailPoet\Mailer\MetaInfo;
|
||||
use MailPoet\Models\Newsletter;
|
||||
use MailPoet\Models\ScheduledTask;
|
||||
use MailPoet\Settings\SettingsController;
|
||||
@ -28,6 +29,9 @@ class AutomatedEmails extends SimpleWorker {
|
||||
/** @var WCHelper */
|
||||
private $woocommerce_helper;
|
||||
|
||||
/** @var MetaInfo */
|
||||
private $mailerMetaInfo;
|
||||
|
||||
/** @var float */
|
||||
public $timer;
|
||||
|
||||
@ -36,6 +40,7 @@ class AutomatedEmails extends SimpleWorker {
|
||||
Renderer $renderer,
|
||||
SettingsController $settings,
|
||||
WCHelper $woocommerce_helper,
|
||||
MetaInfo $mailerMetaInfo,
|
||||
$timer = false
|
||||
) {
|
||||
parent::__construct($timer);
|
||||
@ -43,6 +48,7 @@ class AutomatedEmails extends SimpleWorker {
|
||||
$this->settings = $settings;
|
||||
$this->renderer = $renderer;
|
||||
$this->woocommerce_helper = $woocommerce_helper;
|
||||
$this->mailerMetaInfo = $mailerMetaInfo;
|
||||
$this->timer = $timer ?: microtime(true);
|
||||
}
|
||||
|
||||
@ -71,7 +77,10 @@ class AutomatedEmails extends SimpleWorker {
|
||||
$settings = $this->settings->get(Worker::SETTINGS_KEY);
|
||||
$newsletters = $this->getNewsletters();
|
||||
if ($newsletters) {
|
||||
$this->mailer->send($this->constructNewsletter($newsletters), $settings['address']);
|
||||
$extra_params = [
|
||||
'meta' => $this->mailerMetaInfo->getStatsNotificationMetaInfo(),
|
||||
];
|
||||
$this->mailer->send($this->constructNewsletter($newsletters), $settings['address'], $extra_params);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
if (WP_DEBUG) {
|
||||
|
@ -6,6 +6,7 @@ use Carbon\Carbon;
|
||||
use MailPoet\Config\Renderer;
|
||||
use MailPoet\Cron\CronHelper;
|
||||
use MailPoet\Mailer\Mailer;
|
||||
use MailPoet\Mailer\MetaInfo;
|
||||
use MailPoet\Models\Newsletter;
|
||||
use MailPoet\Models\NewsletterLink;
|
||||
use MailPoet\Models\ScheduledTask;
|
||||
@ -35,11 +36,15 @@ class Worker {
|
||||
/** @var WCHelper */
|
||||
private $woocommerce_helper;
|
||||
|
||||
/** @var MetaInfo */
|
||||
private $mailerMetaInfo;
|
||||
|
||||
function __construct(
|
||||
Mailer $mailer,
|
||||
Renderer $renderer,
|
||||
SettingsController $settings,
|
||||
WCHelper $woocommerce_helper,
|
||||
MetaInfo $mailerMetaInfo,
|
||||
$timer = false
|
||||
) {
|
||||
$this->timer = $timer ?: microtime(true);
|
||||
@ -47,6 +52,7 @@ class Worker {
|
||||
$this->mailer = $mailer;
|
||||
$this->settings = $settings;
|
||||
$this->woocommerce_helper = $woocommerce_helper;
|
||||
$this->mailerMetaInfo = $mailerMetaInfo;
|
||||
}
|
||||
|
||||
/** @throws \Exception */
|
||||
@ -54,7 +60,10 @@ class Worker {
|
||||
$settings = $this->settings->get(self::SETTINGS_KEY);
|
||||
foreach (self::getDueTasks() as $task) {
|
||||
try {
|
||||
$this->mailer->send($this->constructNewsletter($task), $settings['address']);
|
||||
$extra_params = [
|
||||
'meta' => $this->mailerMetaInfo->getStatsNotificationMetaInfo(),
|
||||
];
|
||||
$this->mailer->send($this->constructNewsletter($task), $settings['address'], $extra_params);
|
||||
} catch (\Exception $e) {
|
||||
if (WP_DEBUG) {
|
||||
throw $e;
|
||||
|
@ -20,6 +20,7 @@ use MailPoet\Services\AuthorizedEmailsController;
|
||||
use MailPoet\Statistics\Track\WooCommercePurchases;
|
||||
use MailPoet\WooCommerce\Helper as WooCommerceHelper;
|
||||
use MailPoet\Mailer\Mailer;
|
||||
use MailPoet\Mailer\MetaInfo;
|
||||
use MailPoet\Settings\SettingsController;
|
||||
use MailPoet\Subscribers\InactiveSubscribersController;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
@ -61,6 +62,9 @@ class WorkersFactory {
|
||||
/** @var SubscribersFinder */
|
||||
private $subscribers_finder;
|
||||
|
||||
/** @var MetaInfo */
|
||||
private $mailerMetaInfo;
|
||||
|
||||
public function __construct(
|
||||
SendingErrorHandler $sending_error_handler,
|
||||
StatsNotificationScheduler $statsNotificationsScheduler,
|
||||
@ -72,7 +76,8 @@ class WorkersFactory {
|
||||
WooCommerceHelper $woocommerce_helper,
|
||||
WooCommercePurchases $woocommerce_purchases,
|
||||
AuthorizedEmailsController $authorized_emails_controller,
|
||||
SubscribersFinder $subscribers_finder
|
||||
SubscribersFinder $subscribers_finder,
|
||||
MetaInfo $mailerMetaInfo
|
||||
) {
|
||||
$this->sending_error_handler = $sending_error_handler;
|
||||
$this->statsNotificationsScheduler = $statsNotificationsScheduler;
|
||||
@ -85,6 +90,7 @@ class WorkersFactory {
|
||||
$this->woocommerce_purchases = $woocommerce_purchases;
|
||||
$this->authorized_emails_controller = $authorized_emails_controller;
|
||||
$this->subscribers_finder = $subscribers_finder;
|
||||
$this->mailerMetaInfo = $mailerMetaInfo;
|
||||
}
|
||||
|
||||
/** @return SchedulerWorker */
|
||||
@ -99,12 +105,12 @@ class WorkersFactory {
|
||||
|
||||
/** @return StatsNotificationsWorker */
|
||||
function createStatsNotificationsWorker($timer) {
|
||||
return new StatsNotificationsWorker($this->mailer, $this->renderer, $this->settings, $this->woocommerce_helper, $timer);
|
||||
return new StatsNotificationsWorker($this->mailer, $this->renderer, $this->settings, $this->woocommerce_helper, $this->mailerMetaInfo, $timer);
|
||||
}
|
||||
|
||||
/** @return StatsNotificationsWorkerForAutomatedEmails */
|
||||
function createStatsNotificationsWorkerForAutomatedEmails($timer) {
|
||||
return new StatsNotificationsWorkerForAutomatedEmails($this->mailer, $this->renderer, $this->settings, $this->woocommerce_helper, $timer);
|
||||
return new StatsNotificationsWorkerForAutomatedEmails($this->mailer, $this->renderer, $this->settings, $this->woocommerce_helper, $this->mailerMetaInfo, $timer);
|
||||
}
|
||||
|
||||
/** @return SendingServiceKeyCheckWorker */
|
||||
|
Reference in New Issue
Block a user