mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Thanks
synced 2024-11-14 18:44:51 +00:00
IP Masking: Do not allow temporary users to thank other users
It has been decided to not allow temporary users to thank other users (see task). This is because the transition between anonymous and temporary account is nearly invisible, and it might be confusing why the thanking ability appears and hides. Bug: T345679 Change-Id: I62e67327c9a80b3da9e98a2dccdd4ec2051f3026
This commit is contained in:
parent
42f2613d3d
commit
9cef38e80f
|
@ -32,7 +32,7 @@ abstract class ApiThank extends ApiBase {
|
|||
}
|
||||
|
||||
protected function dieOnBadUser( User $user ) {
|
||||
if ( $user->isAnon() ) {
|
||||
if ( !$user->isNamed() ) {
|
||||
$this->dieWithError( 'thanks-error-notloggedin', 'notloggedin' );
|
||||
} elseif ( $user->pingLimiter( 'thanks-notification' ) ) {
|
||||
$this->dieWithError( [ 'thanks-error-ratelimited', $user->getName() ], 'ratelimited' );
|
||||
|
|
|
@ -127,11 +127,12 @@ class Hooks implements
|
|||
|
||||
// Don't let users thank themselves.
|
||||
// Exclude anonymous users.
|
||||
// Exclude temp users (T345679)
|
||||
// Exclude users who are blocked.
|
||||
// Check whether bots are allowed to receive thanks.
|
||||
// Don't allow thanking for a diff that includes multiple revisions
|
||||
// Check whether we have a revision id to link to
|
||||
if ( $userIdentity->isRegistered()
|
||||
if ( $user->isNamed()
|
||||
&& !$userIdentity->equals( $recipient )
|
||||
&& !self::isUserBlockedFromTitle( $user, $revisionRecord->getPageAsLinkTarget() )
|
||||
&& !self::isUserBlockedFromThanks( $user )
|
||||
|
|
|
@ -44,17 +44,17 @@ class ApiCoreThankUnitTest extends ApiTestCase {
|
|||
* @covers \MediaWiki\Extension\Thanks\Api\ApiThank::dieOnUserBlockedFromThanks
|
||||
*/
|
||||
public function testDieOnBadUser(
|
||||
$mockAnon,
|
||||
$mockisNamed,
|
||||
$mockPingLimited,
|
||||
$mockBlock,
|
||||
$dieMethod,
|
||||
$expectedError
|
||||
) {
|
||||
$user = $this->createMock( User::class );
|
||||
if ( $mockAnon !== null ) {
|
||||
if ( $mockisNamed !== null ) {
|
||||
$user->expects( $this->once() )
|
||||
->method( 'isAnon' )
|
||||
->willReturn( $mockAnon );
|
||||
->method( 'isNamed' )
|
||||
->willReturn( $mockisNamed );
|
||||
}
|
||||
if ( $mockPingLimited !== null ) {
|
||||
$user->expects( $this->once() )
|
||||
|
@ -83,14 +83,14 @@ class ApiCoreThankUnitTest extends ApiTestCase {
|
|||
public static function provideDieOnBadUser() {
|
||||
return [
|
||||
'anon' => [
|
||||
true,
|
||||
false,
|
||||
null,
|
||||
null,
|
||||
'dieOnBadUser',
|
||||
'notloggedin'
|
||||
],
|
||||
'ping' => [
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
null,
|
||||
'dieOnBadUser',
|
||||
|
|
Loading…
Reference in a new issue