mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-27 17:20:40 +00:00
Maintenance script sends notifications immediately
Update the "processEchoEmailBatch" to allow sending all notifications immediately even if configured to be daily or weekly. Change-Id: I6ebeea86708247700d1950e0f6471c7b3d1fecd2
This commit is contained in:
parent
964e93f968
commit
3bfa823922
|
@ -35,9 +35,13 @@ abstract class MWEchoEmailBatch {
|
|||
* 1 - once everyday
|
||||
* 7 - once every 7 days
|
||||
* @param $userId int
|
||||
* @param $enforceFrequency boolean Whether or not email sending frequency should be enforced.
|
||||
* When true, today's notifications won't be returned if their are
|
||||
* configured to go out tonight or at the end of the week.
|
||||
* When false, all pending notifications will be returned.
|
||||
* @return MWEchoEmailBatch/false
|
||||
*/
|
||||
public static function newFromUserId( $userId ) {
|
||||
public static function newFromUserId( $userId, $enforceFrequency = true ) {
|
||||
$batchClassName = self::getEmailBatchClass();
|
||||
|
||||
$user = User::newFromId( intval( $userId ) );
|
||||
|
@ -71,7 +75,7 @@ abstract class MWEchoEmailBatch {
|
|||
if ( $userLastBatch ) {
|
||||
// use 20 as hours per day to get estimate
|
||||
$nextBatch = wfTimestamp( TS_UNIX, $userLastBatch ) + $userEmailSetting * 20 * 60 * 60;
|
||||
if ( wfTimestamp( TS_MW, $nextBatch ) > wfTimestampNow() ) {
|
||||
if ( $enforceFrequency && wfTimestamp( TS_MW, $nextBatch ) > wfTimestampNow() ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,11 +20,18 @@ class ProcessEchoEmailBatch extends Maintenance {
|
|||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->mDescription = "Process email digest";
|
||||
|
||||
$this->addOption(
|
||||
"ignoreConfiguredSchedule",
|
||||
"Send all pending notifications immediately even if configured to be weekly or daily.",
|
||||
false, false, "i" );
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
global $wgEchoCluster;
|
||||
|
||||
$ignoreConfiguredSchedule = $this->getOption( "ignoreConfiguredSchedule", 0 );
|
||||
|
||||
$this->output( "Started processing... \n" );
|
||||
|
||||
$startUserId = 0;
|
||||
|
@ -39,7 +46,7 @@ class ProcessEchoEmailBatch extends Maintenance {
|
|||
foreach ( $res as $row ) {
|
||||
$userId = intval( $row->eeb_user_id );
|
||||
if ( $userId && $userId > $startUserId ) {
|
||||
$emailBatch = MWEchoEmailBatch::newFromUserId( $userId );
|
||||
$emailBatch = MWEchoEmailBatch::newFromUserId( $userId, !$ignoreConfiguredSchedule );
|
||||
if ( $emailBatch ) {
|
||||
$this->output( "processing user_Id " . $userId . " \n" );
|
||||
$emailBatch->process();
|
||||
|
|
Loading…
Reference in a new issue