mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-23 23:44:53 +00:00
Merge "Namespace Controller"
This commit is contained in:
commit
f4a68c4c77
|
@ -1101,11 +1101,9 @@
|
|||
"MediaWiki\\Extension\\Notifications\\Formatters\\EchoMentionPresentationModel": "includes/Formatters/EchoMentionPresentationModel.php",
|
||||
"EchoMentionStatusPresentationModel": "includes/Formatters/EchoMentionStatusPresentationModel.php",
|
||||
"MediaWiki\\Extension\\Notifications\\Formatters\\EchoMentionStatusPresentationModel": "includes/Formatters/EchoMentionStatusPresentationModel.php",
|
||||
"EchoModerationController": "includes/controller/ModerationController.php",
|
||||
"EchoMultipleIterator": "includes/iterator/MultipleIterator.php",
|
||||
"EchoNotRecursiveIterator": "includes/iterator/NotRecursiveIterator.php",
|
||||
"EchoNotification": "includes/model/Notification.php",
|
||||
"EchoNotificationController": "includes/controller/NotificationController.php",
|
||||
"EchoNotificationDeleteJob": "includes/jobs/NotificationDeleteJob.php",
|
||||
"EchoNotificationJob": "includes/jobs/NotificationJob.php",
|
||||
"EchoNotificationMapper": "includes/mapper/NotificationMapper.php",
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace MediaWiki\Extension\Notifications\Api;
|
|||
|
||||
use ApiBase;
|
||||
use EchoAttributeManager;
|
||||
use EchoNotificationController;
|
||||
use MediaWiki\Extension\Notifications\Controller\NotificationController;
|
||||
use MWEchoDbFactory;
|
||||
use MWEchoNotifUser;
|
||||
use WikiMap;
|
||||
|
@ -67,13 +67,13 @@ class ApiEchoMarkRead extends ApiBase {
|
|||
foreach ( EchoAttributeManager::$sections as $section ) {
|
||||
$rawSectionCount = $notifUser->getNotificationCount( $section );
|
||||
$result[$section]['rawcount'] = $rawSectionCount;
|
||||
$result[$section]['count'] = EchoNotificationController::formatNotificationCount( $rawSectionCount );
|
||||
$result[$section]['count'] = NotificationController::formatNotificationCount( $rawSectionCount );
|
||||
$rawCount += $rawSectionCount;
|
||||
}
|
||||
|
||||
$result += [
|
||||
'rawcount' => $rawCount,
|
||||
'count' => EchoNotificationController::formatNotificationCount( $rawCount ),
|
||||
'count' => NotificationController::formatNotificationCount( $rawCount ),
|
||||
];
|
||||
|
||||
$this->getResult()->addValue( 'query', $this->getModuleName(), $result );
|
||||
|
|
|
@ -11,10 +11,10 @@ use EchoAttributeManager;
|
|||
use EchoDataOutputFormatter;
|
||||
use EchoForeignNotifications;
|
||||
use EchoNotification;
|
||||
use EchoNotificationController;
|
||||
use EchoNotificationMapper;
|
||||
use EchoSeenTime;
|
||||
use EchoServices;
|
||||
use MediaWiki\Extension\Notifications\Controller\NotificationController;
|
||||
use MWEchoNotifUser;
|
||||
use Title;
|
||||
use User;
|
||||
|
@ -357,12 +357,12 @@ class ApiEchoNotifications extends ApiQueryBase {
|
|||
$rawCount = $notifUser->getNotificationCount( $section, $global );
|
||||
if ( $groupBySection ) {
|
||||
$result[$section]['rawcount'] = $rawCount;
|
||||
$result[$section]['count'] = EchoNotificationController::formatNotificationCount( $rawCount );
|
||||
$result[$section]['count'] = NotificationController::formatNotificationCount( $rawCount );
|
||||
}
|
||||
$totalRawCount += $rawCount;
|
||||
}
|
||||
$result['rawcount'] = $totalRawCount;
|
||||
$result['count'] = EchoNotificationController::formatNotificationCount( $totalRawCount );
|
||||
$result['count'] = NotificationController::formatNotificationCount( $totalRawCount );
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
@ -541,7 +541,7 @@ class ApiEchoNotifications extends ApiQueryBase {
|
|||
foreach ( $results as $result ) {
|
||||
$primary[$section]['rawcount'] += $result[$section]['rawcount'];
|
||||
}
|
||||
$primary[$section]['count'] = EchoNotificationController::formatNotificationCount(
|
||||
$primary[$section]['count'] = NotificationController::formatNotificationCount(
|
||||
$primary[$section]['rawcount'] );
|
||||
}
|
||||
}
|
||||
|
@ -553,7 +553,7 @@ class ApiEchoNotifications extends ApiQueryBase {
|
|||
// regardless of groupbysection, totals are always included
|
||||
$primary['rawcount'] += $result['rawcount'];
|
||||
}
|
||||
$primary['count'] = EchoNotificationController::formatNotificationCount( $primary['rawcount'] );
|
||||
$primary['count'] = NotificationController::formatNotificationCount( $primary['rawcount'] );
|
||||
|
||||
return $primary;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\Notifications\Controller;
|
||||
|
||||
use DeferredUpdates;
|
||||
use EchoEventMapper;
|
||||
use EchoNotificationMapper;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MWEchoNotifUser;
|
||||
use MWException;
|
||||
use User;
|
||||
|
||||
/**
|
||||
* This class represents the controller for moderating notifications
|
||||
*/
|
||||
class EchoModerationController {
|
||||
class ModerationController {
|
||||
|
||||
/**
|
||||
* Moderate or unmoderate events
|
|
@ -1,15 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\Notifications\Controller;
|
||||
|
||||
use DeferredUpdates;
|
||||
use EchoAttributeManager;
|
||||
use EchoCachedList;
|
||||
use EchoContainmentList;
|
||||
use EchoContainmentSet;
|
||||
use EchoEvent;
|
||||
use EchoFilteredSequentialIterator;
|
||||
use EchoNotificationDeleteJob;
|
||||
use EchoNotificationJob;
|
||||
use EchoOnWikiList;
|
||||
use EchoServices;
|
||||
use Hooks;
|
||||
use Iterator;
|
||||
use MapCacheLRU;
|
||||
use MediaWiki\Extension\Notifications\Exception\CatchableFatalErrorException;
|
||||
use MediaWiki\Logger\LoggerFactory;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Revision\RevisionStore;
|
||||
use MediaWiki\User\UserIdentity;
|
||||
use MWEchoNotifUser;
|
||||
use MWException;
|
||||
use Title;
|
||||
use User;
|
||||
|
||||
/**
|
||||
* This class represents the controller for notifications
|
||||
*/
|
||||
class EchoNotificationController {
|
||||
class NotificationController {
|
||||
|
||||
/**
|
||||
* Echo maximum number of users to cache
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\Extension\Notifications\Controller\ModerationController;
|
||||
use MediaWiki\Logger\LoggerFactory;
|
||||
|
||||
/**
|
||||
|
@ -68,7 +69,7 @@ class EchoDeferredMarkAsDeletedUpdate implements DeferrableUpdate {
|
|||
$events
|
||||
);
|
||||
|
||||
EchoModerationController::moderate( $eventIds, true );
|
||||
ModerationController::moderate( $eventIds, true );
|
||||
$this->events = [];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
namespace MediaWiki\Extension\Notifications\Formatters;
|
||||
|
||||
use EchoEvent;
|
||||
use EchoNotificationController;
|
||||
use InvalidArgumentException;
|
||||
use JsonSerializable;
|
||||
use Language;
|
||||
use MediaWiki\Extension\Notifications\Controller\NotificationController;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Revision\RevisionRecord;
|
||||
use Message;
|
||||
|
@ -264,7 +264,7 @@ abstract class EchoEventPresentationModel implements JsonSerializable, MessageLo
|
|||
*/
|
||||
final protected function getNotificationCountForOutput( $includeCurrent = true, $groupCallback = null ) {
|
||||
$count = $this->getBundleCount( $includeCurrent, $groupCallback );
|
||||
return EchoNotificationController::getCappedNotificationCount( $count );
|
||||
return NotificationController::getCappedNotificationCount( $count );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace MediaWiki\Extension\Notifications\Formatters;
|
||||
|
||||
use EchoEvent;
|
||||
use EchoNotificationController;
|
||||
use MediaWiki\Extension\Notifications\Controller\NotificationController;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use SpecialPage;
|
||||
use Title;
|
||||
|
@ -72,7 +72,7 @@ class EchoPageLinkedPresentationModel extends EchoEventPresentationModel {
|
|||
return null;
|
||||
}
|
||||
$title = $this->event->getTitle();
|
||||
$isPageMuted = EchoNotificationController::isPageLinkedTitleMutedByUser( $title, $this->getUser() );
|
||||
$isPageMuted = NotificationController::isPageLinkedTitleMutedByUser( $title, $this->getUser() );
|
||||
$action = $isPageMuted ? 'unmute' : 'mute';
|
||||
$prefTitle = SpecialPage::getTitleFor( 'Preferences', false, 'mw-prefsection-echo-mutedpageslist' );
|
||||
$data = [
|
||||
|
|
|
@ -13,9 +13,7 @@ use EchoEmailFormat;
|
|||
use EchoEmailFrequency;
|
||||
use EchoEvent;
|
||||
use EchoEventMapper;
|
||||
use EchoModerationController;
|
||||
use EchoNotification;
|
||||
use EchoNotificationController;
|
||||
use EchoNotificationMapper;
|
||||
use EchoSeenTime;
|
||||
use EchoServices;
|
||||
|
@ -29,6 +27,8 @@ use MailAddress;
|
|||
use MediaWiki\Api\Hook\ApiMain__moduleManagerHook;
|
||||
use MediaWiki\Auth\Hook\LocalUserCreatedHook;
|
||||
use MediaWiki\DAO\WikiAwareEntity;
|
||||
use MediaWiki\Extension\Notifications\Controller\ModerationController;
|
||||
use MediaWiki\Extension\Notifications\Controller\NotificationController;
|
||||
use MediaWiki\Extension\Notifications\Formatters\EchoEventPresentationModel;
|
||||
use MediaWiki\Extension\Notifications\Push\Api\ApiEchoPushSubscriptions;
|
||||
use MediaWiki\Hook\AbortTalkPageEmailNotificationHook;
|
||||
|
@ -1084,8 +1084,8 @@ class Hooks implements
|
|||
'notice' => $seenMsgTime,
|
||||
] );
|
||||
|
||||
$msgFormattedCount = EchoNotificationController::formatNotificationCount( $msgCount );
|
||||
$alertFormattedCount = EchoNotificationController::formatNotificationCount( $alertCount );
|
||||
$msgFormattedCount = NotificationController::formatNotificationCount( $msgCount );
|
||||
$alertFormattedCount = NotificationController::formatNotificationCount( $alertCount );
|
||||
|
||||
$url = SpecialPage::getTitleFor( 'Notifications' )->getLocalURL();
|
||||
|
||||
|
@ -1637,7 +1637,7 @@ class Hooks implements
|
|||
DeferredUpdates::addCallableUpdate( static function () use ( $articleId ) {
|
||||
$eventMapper = new EchoEventMapper();
|
||||
$eventIds = $eventMapper->fetchIdsByPage( $articleId );
|
||||
EchoModerationController::moderate( $eventIds, true );
|
||||
ModerationController::moderate( $eventIds, true );
|
||||
} );
|
||||
}
|
||||
|
||||
|
@ -1653,7 +1653,7 @@ class Hooks implements
|
|||
DeferredUpdates::addCallableUpdate( static function () use ( $oldPageId ) {
|
||||
$eventMapper = new EchoEventMapper();
|
||||
$eventIds = $eventMapper->fetchIdsByPage( $oldPageId );
|
||||
EchoModerationController::moderate( $eventIds, false );
|
||||
ModerationController::moderate( $eventIds, false );
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\Extension\Notifications\Controller\NotificationController;
|
||||
|
||||
class EchoNotificationJob extends Job {
|
||||
|
||||
public function __construct( Title $title, array $params ) {
|
||||
|
@ -10,7 +12,7 @@ class EchoNotificationJob extends Job {
|
|||
public function run() {
|
||||
$eventMapper = new EchoEventMapper();
|
||||
$event = $eventMapper->fetchById( $this->params['eventId'], true );
|
||||
EchoNotificationController::notify( $event, false );
|
||||
NotificationController::notify( $event, false );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\Extension\Notifications\Controller\NotificationController;
|
||||
use MediaWiki\Logger\LoggerFactory;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Revision\RevisionRecord;
|
||||
|
@ -187,7 +188,7 @@ class EchoEvent extends EchoAbstractEntity implements Bundleable {
|
|||
|
||||
global $wgEchoUseJobQueue;
|
||||
|
||||
EchoNotificationController::notify( $obj, $wgEchoUseJobQueue );
|
||||
NotificationController::notify( $obj, $wgEchoUseJobQueue );
|
||||
|
||||
$stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
|
||||
$type = $info['type'];
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\Extension\Notifications\Controller\NotificationController;
|
||||
use MediaWiki\User\UserOptionsLookup;
|
||||
use Wikimedia\TestingAccessWrapper;
|
||||
|
||||
/**
|
||||
* @covers \EchoNotificationController
|
||||
* @covers \MediaWiki\Extension\Notifications\Controller\NotificationController
|
||||
*/
|
||||
class NotificationControllerTest extends MediaWikiIntegrationTestCase {
|
||||
|
||||
|
@ -90,7 +91,7 @@ class NotificationControllerTest extends MediaWikiIntegrationTestCase {
|
|||
$setup( $this, $event );
|
||||
}
|
||||
|
||||
$result = EchoNotificationController::evaluateUserCallable( $event, EchoAttributeManager::ATTR_LOCATORS );
|
||||
$result = NotificationController::evaluateUserCallable( $event, EchoAttributeManager::ATTR_LOCATORS );
|
||||
$this->assertEquals( $expect, array_map( 'array_keys', $result ), $message );
|
||||
}
|
||||
|
||||
|
@ -160,7 +161,7 @@ class NotificationControllerTest extends MediaWikiIntegrationTestCase {
|
|||
$event->method( 'getType' )
|
||||
->willReturn( 'unit-test' );
|
||||
|
||||
$result = EchoNotificationController::getUsersToNotifyForEvent( $event );
|
||||
$result = NotificationController::getUsersToNotifyForEvent( $event );
|
||||
$ids = [];
|
||||
foreach ( $result as $user ) {
|
||||
$ids[] = $user->getId();
|
||||
|
@ -177,7 +178,7 @@ class NotificationControllerTest extends MediaWikiIntegrationTestCase {
|
|||
$event->expects( $this->never() )
|
||||
->method( 'getType' );
|
||||
|
||||
EchoNotificationController::notify( $event, false );
|
||||
NotificationController::notify( $event, false );
|
||||
}
|
||||
|
||||
public static function getEventNotifyTypesProvider() {
|
||||
|
@ -251,7 +252,7 @@ class NotificationControllerTest extends MediaWikiIntegrationTestCase {
|
|||
[ 'priority' => 4 ]
|
||||
),
|
||||
] );
|
||||
$result = EchoNotificationController::getEventNotifyTypes( $type );
|
||||
$result = NotificationController::getEventNotifyTypes( $type );
|
||||
$this->assertEquals( $expect, $result, $message );
|
||||
}
|
||||
|
||||
|
@ -265,7 +266,7 @@ class NotificationControllerTest extends MediaWikiIntegrationTestCase {
|
|||
$event->expects( $this->once() )
|
||||
->method( 'getId' )
|
||||
->willReturn( 42 );
|
||||
EchoNotificationController::enqueueEvent( $event );
|
||||
NotificationController::enqueueEvent( $event );
|
||||
$jobQueueGroup = $this->getServiceContainer()->getJobQueueGroup();
|
||||
$queues = $jobQueueGroup->getQueuesWithJobs();
|
||||
$this->assertCount( 1, $queues );
|
||||
|
@ -293,7 +294,7 @@ class NotificationControllerTest extends MediaWikiIntegrationTestCase {
|
|||
->willReturn( Title::newFromText( 'test-title' ) );
|
||||
$event->method( 'getId' )
|
||||
->willReturn( 42 );
|
||||
EchoNotificationController::enqueueEvent( $event );
|
||||
NotificationController::enqueueEvent( $event );
|
||||
|
||||
$this->assertCount( 0, $queueGroup->getQueuesWithJobs() );
|
||||
}
|
||||
|
@ -315,7 +316,7 @@ class NotificationControllerTest extends MediaWikiIntegrationTestCase {
|
|||
->method( 'getId' )
|
||||
->willReturn( 42 );
|
||||
|
||||
$params = EchoNotificationController::getEventParams( $event );
|
||||
$params = NotificationController::getEventParams( $event );
|
||||
$expectedParams = [
|
||||
'eventId' => 42,
|
||||
'rootJobSignature' => 'test-signature',
|
||||
|
@ -327,7 +328,6 @@ class NotificationControllerTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider PageLinkedTitleMutedByUserDataProvider
|
||||
* @covers EchoNotificationController::isPageLinkedTitleMutedByUser
|
||||
* @param Title $title
|
||||
* @param User $user
|
||||
* @param UserOptionsLookup $userOptionsLookup
|
||||
|
@ -335,7 +335,7 @@ class NotificationControllerTest extends MediaWikiIntegrationTestCase {
|
|||
*/
|
||||
public function testIsPageLinkedTitleMutedByUser(
|
||||
Title $title, User $user, UserOptionsLookup $userOptionsLookup, $expected ): void {
|
||||
$wrapper = TestingAccessWrapper::newFromClass( EchoNotificationController::class );
|
||||
$wrapper = TestingAccessWrapper::newFromClass( NotificationController::class );
|
||||
$wrapper->mutedPageLinkedTitlesCache = $this->createMock( MapCacheLRU::class );
|
||||
$this->setService( 'UserOptionsLookup', $userOptionsLookup );
|
||||
$this->assertSame(
|
Loading…
Reference in a new issue