mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 22:28:51 +01:00
Added activity mail summary queuing
This commit is contained in:
parent
e149b8be7e
commit
e0720e9964
@ -9,8 +9,8 @@
|
||||
namespace humhub\modules\activity;
|
||||
|
||||
use Yii;
|
||||
use humhub\modules\activity\components\MailSummaryProcessor;
|
||||
use humhub\modules\activity\components\MailSummary;
|
||||
use humhub\modules\activity\jobs\SendMailSummary;
|
||||
use humhub\modules\activity\models\Activity;
|
||||
|
||||
/**
|
||||
@ -29,9 +29,9 @@ class Events extends \yii\base\Object
|
||||
public static function onCronRun($event)
|
||||
{
|
||||
if (Yii::$app->controller->action->id == 'hourly') {
|
||||
MailSummaryProcessor::process(MailSummary::INTERVAL_HOURY);
|
||||
Yii::$app->queue->push(new SendMailSummary(['interval' => MailSummary::INTERVAL_HOURY]));
|
||||
} elseif (Yii::$app->controller->action->id == 'daily') {
|
||||
MailSummaryProcessor::process(MailSummary::INTERVAL_DAILY);
|
||||
Yii::$app->queue->push(new SendMailSummary(['interval' => MailSummary::INTERVAL_DAILY]));
|
||||
}
|
||||
}
|
||||
|
||||
|
43
protected/humhub/modules/activity/jobs/SendMailSummary.php
Normal file
43
protected/humhub/modules/activity/jobs/SendMailSummary.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @link https://www.humhub.org/
|
||||
* @copyright Copyright (c) 2017 HumHub GmbH & Co. KG
|
||||
* @license https://www.humhub.com/licences
|
||||
*/
|
||||
|
||||
namespace humhub\modules\activity\jobs;
|
||||
|
||||
use Yii;
|
||||
use humhub\components\queue\ActiveJob;
|
||||
use humhub\modules\activity\components\MailSummaryProcessor;
|
||||
use humhub\modules\activity\components\MailSummary;
|
||||
|
||||
/**
|
||||
* SendMailSummary
|
||||
*
|
||||
* @since 1.2
|
||||
* @author Luke
|
||||
*/
|
||||
class SendMailSummary extends ActiveJob
|
||||
{
|
||||
|
||||
/**
|
||||
* @var int the interval
|
||||
*/
|
||||
public $interval;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
if ($this->interval === MailSummary::INTERVAL_DAILY || $this->interval === MailSummary::INTERVAL_HOURY) {
|
||||
MailSummaryProcessor::process($this->interval);
|
||||
} else {
|
||||
Yii::error('Invalid summary interval given'. $this->interval, 'activity.job');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user