Added QueueManager to process background jobs

This commit is contained in:
Frederic Guillot
2016-05-23 20:43:51 -04:00
parent dc6176fca2
commit 8314c99b56
29 changed files with 427 additions and 34 deletions

View File

@@ -2,6 +2,7 @@
namespace Kanboard\Core\Mail;
use Kanboard\Job\EmailJob;
use Pimple\Container;
use Kanboard\Core\Base;
@@ -46,25 +47,31 @@ class Client extends Base
public function send($email, $name, $subject, $html)
{
if (! empty($email)) {
$this->logger->debug('Sending email to '.$email.' ('.MAIL_TRANSPORT.')');
$start_time = microtime(true);
$author = 'Kanboard';
if ($this->userSession->isLogged()) {
$author = e('%s via Kanboard', $this->helper->user->getFullname());
}
$this->getTransport(MAIL_TRANSPORT)->sendEmail($email, $name, $subject, $html, $author);
if (DEBUG) {
$this->logger->debug('Email sent in '.round(microtime(true) - $start_time, 6).' seconds');
}
$this->queueManager->push(EmailJob::getInstance($this->container)
->withParams($email, $name, $subject, $html, $this->getAuthor())
);
}
return $this;
}
/**
* Get email author
*
* @access public
* @return string
*/
public function getAuthor()
{
$author = 'Kanboard';
if ($this->userSession->isLogged()) {
$author = e('%s via Kanboard', $this->helper->user->getFullname());
}
return $author;
}
/**
* Get mail transport instance
*