X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialEmailuser.php;h=f322ac40ef48c59f122d0b2a3e6fe625a875287d;hb=40ced7e89ca9cd6896cd37b4b35051ed5754eb44;hp=249be7f17fa9a658005262d5276d3f8116830005;hpb=732b5e2745ca8f6153e19cc10c3c9acb1b2a6331;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialEmailuser.php b/includes/specials/SpecialEmailuser.php index 249be7f17f..f322ac40ef 100644 --- a/includes/specials/SpecialEmailuser.php +++ b/includes/specials/SpecialEmailuser.php @@ -224,15 +224,29 @@ class SpecialEmailUser extends UnlistedSpecialPage { wfDebug( "Target is invalid user.\n" ); return 'notarget'; - } elseif ( !$target->isEmailConfirmed() ) { + } + + if ( !$target->isEmailConfirmed() ) { wfDebug( "User has no valid email.\n" ); return 'noemail'; - } elseif ( !$target->canReceiveEmail() ) { + } + + if ( !$target->canReceiveEmail() ) { wfDebug( "User does not allow user emails.\n" ); return 'nowikiemail'; - } elseif ( $sender !== null ) { + } + + if ( $sender !== null && !$target->getOption( 'email-allow-new-users' ) && + $sender->isNewbie() + ) { + wfDebug( "User does not allow user emails from new users.\n" ); + + return 'nowikiemail'; + } + + if ( $sender !== null ) { $blacklist = $target->getOption( 'email-blacklist', [] ); if ( $blacklist ) { $lookup = CentralIdLookup::factory(); @@ -280,7 +294,9 @@ class SpecialEmailUser extends UnlistedSpecialPage { return "blockedemailuser"; } - if ( $user->pingLimiter( 'emailuser' ) ) { + // Check the ping limiter without incrementing it - we'll check it + // again later and increment it on a successful send + if ( $user->pingLimiter( 'emailuser', 0 ) ) { wfDebug( "Ping limiter triggered.\n" ); return 'actionthrottledtext'; @@ -376,6 +392,11 @@ class SpecialEmailUser extends UnlistedSpecialPage { $text .= $context->msg( 'emailuserfooter', $from->name, $to->name )->inContentLanguage()->text(); + // Check and increment the rate limits + if ( $context->getUser()->pingLimiter( 'emailuser' ) ) { + throw new ThrottledError(); + } + $error = false; if ( !Hooks::run( 'EmailUser', [ &$to, &$from, &$subject, &$text, &$error ] ) ) { if ( $error instanceof Status ) {