Check settings before processing task

[MAILPOET-1859]
This commit is contained in:
Pavel Dohnal
2019-07-17 13:33:12 +02:00
committed by M. Shull
parent fe406bf045
commit 8f5fb52f15

View File

@@ -21,8 +21,30 @@ class AutomatedEmails extends SimpleWorker {
$this->settings = $settings;
}
function checkProcessingRequirements() {
$settings = $this->settings->get(Worker::SETTINGS_KEY);
if (!is_array($settings)) {
return false;
}
if (!isset($settings['automated'])) {
return false;
}
if (!isset($settings['address'])) {
return false;
}
if (empty(trim($settings['address']))) {
return false;
}
if (!(bool)$this->settings->get('tracking.enabled')) {
return false;
}
return (bool)$settings['automated'];
}
function processTaskStrategy(ScheduledTask $task) {
// TODO
// TODO refactor \MailPoet\Cron\Workers\StatsNotifications\Worker and Scheduler and share the code
// TODO refactor the views templates mailpoet/views/emails/statsNotification.html and txt and share them
}
static function getNextRunDate() {