mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-14 19:28:31 +00:00
Merge "Don't send page-linked notifications for pages created by bot users"
This commit is contained in:
commit
84966452f8
|
@ -131,6 +131,10 @@ class EchoUserLocator {
|
|||
|
||||
$user = User::newFromId( $res->rev_user );
|
||||
if ( $user ) {
|
||||
// T318523: Don't send page-linked notifications for pages created by bot users.
|
||||
if ( $event->getType() === 'page-linked' && $user->isBot() ) {
|
||||
return [];
|
||||
}
|
||||
return [ $user->getId() => $user ];
|
||||
}
|
||||
|
||||
|
|
|
@ -130,6 +130,37 @@ class UserLocatorTest extends MediaWikiIntegrationTestCase {
|
|||
$this->assertEquals( $expect, array_keys( $users ), $message );
|
||||
}
|
||||
|
||||
public function testDontSendPageLinkedNotificationsForPagesCreatedByBotUsers() {
|
||||
$botUser = $this->getTestUser( [ 'bot' ] )->getUser();
|
||||
$botUser->addToDatabase();
|
||||
$this->editPage( 'TestBotCreatedPage', 'Test', '', NS_MAIN, $botUser );
|
||||
$this->editPage( 'SomeOtherPage', '[[TestBotCreatedPage]]' );
|
||||
$event = $this->createMock( Event::class );
|
||||
$event->method( 'getTitle' )
|
||||
->willReturn( Title::newFromText( 'TestBotCreatedPage' ) );
|
||||
$event->method( 'getAgent' )
|
||||
->willReturn( User::newFromId( 123 ) );
|
||||
$event->method( 'getType' )
|
||||
->willReturn( 'page-linked' );
|
||||
$this->assertEquals( [], EchoUserLocator::locateArticleCreator( $event ) );
|
||||
|
||||
$normalUser = $this->getTestUser()->getUser();
|
||||
$normalUser->addToDatabase();
|
||||
$this->editPage( 'NormalCreatedPage', 'Test', '', NS_MAIN, $normalUser );
|
||||
$this->editPage( 'AnotherPage', '[[NormalCreatedPage]]' );
|
||||
$event = $this->createMock( Event::class );
|
||||
$event->method( 'getTitle' )
|
||||
->willReturn( Title::newFromText( 'NormalCreatedPage' ) );
|
||||
$event->method( 'getAgent' )
|
||||
->willReturn( User::newFromId( 456 ) );
|
||||
$event->method( 'getType' )
|
||||
->willReturn( 'page-linked' );
|
||||
$this->assertEquals(
|
||||
$normalUser->getUser()->getId(),
|
||||
array_key_first( EchoUserLocator::locateArticleCreator( $event ) )
|
||||
);
|
||||
}
|
||||
|
||||
public static function locateEventAgentProvider() {
|
||||
return [
|
||||
[
|
||||
|
|
Loading…
Reference in a new issue