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

This patch makes Echo talk page notification mimic the existing Orange Bar and Email talk page notification
for minor edit.

For the Orange Bar, minor edit notification is sent if the editor does not have nominornewtalk
permission.

There are additional rules for the email, minor edit notification is sent if global $wgEnotifMinorEdit
is true and notification recipient has enotifminoredits option on.

Change-Id: Ib3835c4dd57a3686b227c44710a14ab06cded166
This commit is contained in:
bsitu 2013-05-01 12:27:32 -07:00
parent 1a7485aa34
commit f47349e303
4 changed files with 37 additions and 6 deletions

View file

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

View file

@ -439,6 +439,28 @@ class EchoHooks {
return true; 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. * Handler for AddNewAccount hook.
* @see http://www.mediawiki.org/wiki/Manual:Hooks/AddNewAccount * @see http://www.mediawiki.org/wiki/Manual:Hooks/AddNewAccount

View file

@ -90,6 +90,11 @@ class EchoNotifier {
return false; 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 // 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' ) ) ) { if ( in_array( $event->getType(), EchoNotificationController::getUserEnabledEvents( $user, 'email' ) ) ) {
global $wgEchoEnableEmailBatch, $wgEchoNotifications, $wgNotificationSender, $wgNotificationSenderName, $wgNotificationReplyName, $wgEchoBundleEmailInterval; 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 // If the recipient is a valid non-anonymous user and hasn't turned
// off thier notifications, generate a talk page post Echo notification. // off thier notifications, generate a talk page post Echo notification.
if ( $notifyUser && $notifyUser->getID() && $notifyUser->getOption( 'echo-notify-show-link' ) ) { if ( $notifyUser && $notifyUser->getID() && $notifyUser->getOption( 'echo-notify-show-link' ) ) {
EchoEvent::create( array( // if this is a minor edit, only notify if the agent doesn't have talk page minor edit notification blocked
'type' => 'edit-user-talk', if ( !$revision->isMinor() || !$user->isAllowed( 'nominornewtalk' ) ) {
'title' => $title, EchoEvent::create( array(
'extra' => array( 'revid' => $revision->getID() ), 'type' => 'edit-user-talk',
'agent' => $user, 'title' => $title,
) ); 'extra' => array( 'revid' => $revision->getID(), 'minoredit' => $revision->isMinor() ),
'agent' => $user,
) );
}
} }
} }
} }