mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-27 17:20:40 +00:00
Merge "(bug 47910) Minor edit should not trigger talk page notif"
This commit is contained in:
commit
bdb4038ceb
1
Echo.php
1
Echo.php
|
@ -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';
|
||||
|
|
22
Hooks.php
22
Hooks.php
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue