Sbisson has uploaded a new change for review. https://gerrit.wikimedia.org/r/228347
Change subject: Suppress notifications during talk page conversion to Flow ...................................................................... Suppress notifications during talk page conversion to Flow - Prevent Echo events from 'Talk page manager' user from being saved. - Prevent 'You have new messages!' notifications when caused by 'Talk page manager' user. Bug: T78576 Change-Id: I4ed66baa44c382aea3944a8cfd16fcb1b1d6edf0 --- M Flow.php M Hooks.php 2 files changed, 43 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow refs/changes/47/228347/1 diff --git a/Flow.php b/Flow.php index 52f49fe..cc92149 100644 --- a/Flow.php +++ b/Flow.php @@ -121,6 +121,8 @@ $wgHooks['AbuseFilter-computeVariable'][] = 'FlowHooks::onAbuseFilterComputeVariable'; $wgHooks['AbortEmailNotification'][] = 'FlowHooks::onAbortEmailNotification'; $wgHooks['EchoAbortEmailNotification'][] = 'FlowHooks::onEchoAbortEmailNotification'; +$wgHooks['BeforeEchoEventInsert'][] = 'FlowHooks::onBeforeEchoEventInsert'; +$wgHooks['ArticleEditUpdateNewTalk'][] = 'FlowHooks::onArticleEditUpdateNewTalk'; $wgHooks['InfoAction'][] = 'FlowHooks::onInfoAction'; $wgHooks['SpecialCheckUserGetLinksFromRow'][] = 'FlowHooks::onSpecialCheckUserGetLinksFromRow'; $wgHooks['CheckUserInsertForRecentChange'][] = 'FlowHooks::onCheckUserInsertForRecentChange'; diff --git a/Hooks.php b/Hooks.php index f194be5..9482cf5 100644 --- a/Hooks.php +++ b/Hooks.php @@ -910,8 +910,7 @@ return false; } - $talkPageManagerUser = self::$occupationController->getTalkpageManager(); - if ( $editor->equals( $talkPageManagerUser ) ) { + if ( self::isTalkpageManagerUser( $editor ) ) { return false; } @@ -919,6 +918,46 @@ } /** + * Suppress all Echo notifications generated by the Talk page manager user + * + * @param EchoEvent $event + * @return bool + */ + public static function onBeforeEchoEventInsert( EchoEvent $event ) { + if ( self::isTalkpageManagerUser( $event->getAgent() ) ) { + return false; + } + + return true; + } + + /** + * Suppress the 'You have new messages!' indication when a change to a + * user talk page is done by the talk page manager user. + * + * @param WikiPage $page + * @param User $recipient + * @return bool + */ + public static function onArticleEditUpdateNewTalk( WikiPage $page, User $recipient ) { + $user = User::newFromId( $page->getUser( Revision::RAW ) ); + if ( self::isTalkpageManagerUser( $user ) ) { + return false; + } + + return true; + } + + /** + * @param User $user + * @return bool + */ + private static function isTalkpageManagerUser( User $user ) { + $talkPageManagerUser = self::$occupationController->getTalkpageManager(); + return $user && $user->equals( $talkPageManagerUser ); + } + + /** * Don't send email notifications that are imported from LiquidThreads. It will * still be in their web notifications (if enabled), but they will never be * notified via email (regardless of batching settings) for this particular -- To view, visit https://gerrit.wikimedia.org/r/228347 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4ed66baa44c382aea3944a8cfd16fcb1b1d6edf0 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: Sbisson <sbis...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits