2013-03-06 00:04:48 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class MWEchoNotificationEmailBundleJob extends Job {
|
|
|
|
function __construct( $title, $params ) {
|
2013-04-17 23:32:07 +00:00
|
|
|
parent::__construct( __CLASS__, $title, $params );
|
2013-03-06 00:04:48 +00:00
|
|
|
// If there is already a job with the same params, this job will be ignored
|
|
|
|
// for example, if there is a page link bundle notification job for article A
|
|
|
|
// created by user B, any subsequent jobs with the same data will be ignored
|
|
|
|
$this->removeDuplicates = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function run() {
|
2013-04-17 23:32:07 +00:00
|
|
|
$bundle = MWEchoEmailBundler::newFromUserHash(
|
|
|
|
User::newFromId( $this->params['user_id'] ),
|
|
|
|
$this->params['bundle_hash']
|
|
|
|
);
|
|
|
|
|
|
|
|
if ( $bundle ) {
|
|
|
|
$bundle->processBundleEmail();
|
2013-03-06 00:04:48 +00:00
|
|
|
} else {
|
2013-04-17 23:32:07 +00:00
|
|
|
throw new MWException( 'Fail to create bundle object for: user_id: ' . $this->params['user_id'] . ', bundle_hash: ' . $this->params['bundle_hash'] );
|
2013-03-06 00:04:48 +00:00
|
|
|
}
|
2013-04-17 23:32:07 +00:00
|
|
|
|
2013-03-06 00:04:48 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|