Schedule a notification

[MAILPOET-1571]
This commit is contained in:
Pavel Dohnal
2019-01-08 13:31:05 +01:00
parent d346a44974
commit 1d34613b17
5 changed files with 55 additions and 25 deletions

View File

@ -5,6 +5,7 @@ use MailPoet\Cron\CronHelper;
use MailPoet\Cron\Workers\SendingQueue\Tasks\Links;
use MailPoet\Cron\Workers\SendingQueue\Tasks\Mailer as MailerTask;
use MailPoet\Cron\Workers\SendingQueue\Tasks\Newsletter as NewsletterTask;
use MailPoet\Cron\Workers\StatsNotifications;
use MailPoet\Logging\Logger;
use MailPoet\Mailer\MailerError;
use MailPoet\Mailer\MailerLog;
@ -25,11 +26,15 @@ class SendingQueue {
const BATCH_SIZE = 20;
const TASK_BATCH_SIZE = 5;
/** @var StatsNotifications */
public $stats_notifications_worker;
/** @var SendingErrorHandler */
private $error_handler;
function __construct(SendingErrorHandler $error_handler, $timer = false, $mailer_task = false, $newsletter_task = false) {
function __construct(SendingErrorHandler $error_handler, StatsNotifications $stats_notifications_worker, $timer = false, $mailer_task = false, $newsletter_task = false) {
$this->error_handler = $error_handler;
$this->stats_notifications_worker = $stats_notifications_worker;
$this->mailer_task = ($mailer_task) ? $mailer_task : new MailerTask();
$this->newsletter_task = ($newsletter_task) ? $newsletter_task : new NewsletterTask();
$this->timer = ($timer) ? $timer : microtime(true);
@ -98,6 +103,7 @@ class SendingQueue {
);
if($queue->status === ScheduledTaskModel::STATUS_COMPLETED) {
$this->newsletter_task->markNewsletterAsSent($newsletter, $queue);
$this->stats_notifications_worker->schedule($newsletter);
}
$this->enforceSendingAndExecutionLimits();
}