Merge "(bug 47910) Minor edit should not trigger talk page notif"

This commit is contained in:
jenkins-bot 2013-05-06 20:50:36 +00:00 committed by Gerrit Code Review
commit bdb4038ceb
4 changed files with 37 additions and 6 deletions

View file

@ -173,6 +173,7 @@ $wgResourceModules += array(
$wgHooks['EchoGetDefaultNotifiedUsers'][] = 'EchoHooks::getDefaultNotifiedUsers';
$wgHooks['EchoGetNotificationTypes'][] = 'EchoHooks::getNotificationTypes';
$wgHooks['EchoGetBundleRules'][] = 'EchoHooks::onEchoGetBundleRules';
$wgHooks['EchoAbortEmailNotification'][] = 'EchoHooks::onEchoAbortEmailNotification';
// Hook appropriate events
$wgHooks['ArticleSaveComplete'][] = 'EchoHooks::onArticleSaved';

View file

@ -439,6 +439,28 @@ class EchoHooks {
return true;
}
/**
* Handler for EchoAbortEmailNotification hook
* @param $user User
* @param $event EchoEvent
* @return bool true - send email, false - do not send email
*/
public static function onEchoAbortEmailNotification( $user, $event ) {
if ( $event->getType() === 'edit-user-talk' ) {
$extra = $event->getExtra();
if ( !empty( $extra['minoredit'] ) ) {
global $wgEnotifMinorEdits;
if ( !$wgEnotifMinorEdits || !$user->getOption( 'enotifminoredits' ) ) {
// Do not send talk page notification email
return false;
}
}
}
// Proceed to send talk page notification email
return true;
}
/**
* Handler for AddNewAccount hook.
* @see http://www.mediawiki.org/wiki/Manual:Hooks/AddNewAccount

View file

@ -90,6 +90,11 @@ class EchoNotifier {
return false;
}
// Final check on whether to send email for this user & event
if ( !wfRunHooks( 'EchoAbortEmailNotification', array( $user, $event ) ) ) {
return false;
}
// See if the user wants to receive emails for this category or the user is eligible to receive this email
if ( in_array( $event->getType(), EchoNotificationController::getUserEnabledEvents( $user, 'email' ) ) ) {
global $wgEchoEnableEmailBatch, $wgEchoNotifications, $wgNotificationSender, $wgNotificationSenderName, $wgNotificationReplyName, $wgEchoBundleEmailInterval;

View file

@ -79,12 +79,15 @@ abstract class EchoDiscussionParser {
// If the recipient is a valid non-anonymous user and hasn't turned
// off thier notifications, generate a talk page post Echo notification.
if ( $notifyUser && $notifyUser->getID() && $notifyUser->getOption( 'echo-notify-show-link' ) ) {
EchoEvent::create( array(
'type' => 'edit-user-talk',
'title' => $title,
'extra' => array( 'revid' => $revision->getID() ),
'agent' => $user,
) );
// if this is a minor edit, only notify if the agent doesn't have talk page minor edit notification blocked
if ( !$revision->isMinor() || !$user->isAllowed( 'nominornewtalk' ) ) {
EchoEvent::create( array(
'type' => 'edit-user-talk',
'title' => $title,
'extra' => array( 'revid' => $revision->getID(), 'minoredit' => $revision->isMinor() ),
'agent' => $user,
) );
}
}
}
}