Merge "Prevent double email notifications on talk page edit"

This commit is contained in:
jenkins-bot 2014-03-19 22:18:21 +00:00 committed by Gerrit Code Review
commit cabdbade1a
2 changed files with 25 additions and 0 deletions

View file

@ -239,6 +239,7 @@ $wgHooks['UserSaveSettings'][] = 'EchoHooks::onUserSaveSettings';
// Disable ordinary user talk page email notifications
$wgHooks['AbortTalkPageEmailNotification'][] = 'EchoHooks::onAbortTalkPageEmailNotification';
$wgHooks['SendWatchlistEmailNotification'][] = 'EchoHooks::onSendWatchlistEmailNotification';
// Disable the yellow bar of death
$wgHooks['GetNewMessagesAlert'][] = 'EchoHooks::abortNewMessagesAlert';
$wgHooks['LinksUpdateAfterInsert'][] = 'EchoHooks::onLinksUpdateAfterInsert';

View file

@ -716,6 +716,30 @@ class EchoHooks {
return false;
}
/**
* Handler for AbortWatchlistEmailNotification hook.
* @see http://www.mediawiki.org/wiki/Manual:Hooks/AbortWatchlistEmailNotification
* @param $targetUser User
* @param $title Title
* @param $emailNotification EmailNotification The email notification object that sends non-echo notifications
* @return bool
*/
static function onSendWatchlistEmailNotification( $targetUser, $title, $emailNotification ) {
// If a user is watching his/her own talk page, do not send talk page watchlist
// email notification if the user is receiving Echo talk page notification
if ( $title->isTalkPage() && $targetUser->getTalkPage()->equals( $title ) ) {
if (
!self::isEchoDisabled( $targetUser )
&& in_array( 'edit-user-talk', EchoNotificationController::getUserEnabledEvents( $targetUser, 'email' ) )
) {
// Do not send watchlist email notification, the user will receive an Echo notification
return false;
}
}
// Proceed to send watchlist email notification
return true;
}
/**
* Handler for MakeGlobalVariablesScript hook.
* @see http://www.mediawiki.org/wiki/Manual:Hooks/MakeGlobalVariablesScript