2012-06-06 07:04:28 +00:00
|
|
|
<?php
|
|
|
|
|
2022-11-02 04:15:17 +00:00
|
|
|
namespace MediaWiki\Extension\Notifications\Jobs;
|
|
|
|
|
|
|
|
use Job;
|
2022-11-02 03:51:15 +00:00
|
|
|
use MediaWiki\Extension\Notifications\Controller\NotificationController;
|
2022-11-02 20:47:04 +00:00
|
|
|
use MediaWiki\Extension\Notifications\Mapper\EventMapper;
|
2024-09-22 09:42:51 +00:00
|
|
|
use MediaWiki\Extension\Notifications\Model\Event;
|
2023-08-19 04:14:59 +00:00
|
|
|
use MediaWiki\Title\Title;
|
2022-11-02 03:51:15 +00:00
|
|
|
|
2022-11-02 04:15:17 +00:00
|
|
|
class NotificationJob extends Job {
|
2018-06-18 16:54:03 +00:00
|
|
|
|
2019-10-23 10:44:35 +00:00
|
|
|
public function __construct( Title $title, array $params ) {
|
2020-10-09 14:09:21 +00:00
|
|
|
$command = isset( $params['jobReleaseTimestamp'] ) ? 'DelayedEchoNotificationJob' : 'EchoNotificationJob';
|
|
|
|
parent::__construct( $command, $title, $params );
|
2012-06-06 07:04:28 +00:00
|
|
|
}
|
|
|
|
|
2018-11-02 17:47:39 +00:00
|
|
|
public function run() {
|
2024-09-22 09:42:51 +00:00
|
|
|
if ( isset( $this->params['eventId'] ) ) {
|
|
|
|
$eventMapper = new EventMapper();
|
|
|
|
$event = $eventMapper->fetchById( $this->params['eventId'], true );
|
|
|
|
} else {
|
|
|
|
$event = Event::newFromArray( $this->params['eventData'] );
|
|
|
|
}
|
2022-11-02 03:51:15 +00:00
|
|
|
NotificationController::notify( $event, false );
|
2015-10-01 13:48:52 +00:00
|
|
|
|
2014-08-02 06:41:19 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-07-18 19:39:33 +00:00
|
|
|
}
|