mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-12 09:26:05 +00:00
Merge "Prevent double email notifications on talk page edit"
This commit is contained in:
commit
cabdbade1a
1
Echo.php
1
Echo.php
|
@ -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';
|
||||
|
|
24
Hooks.php
24
Hooks.php
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue