New logic for how Echo interacts with new message alerts (OBOD)

Previously Echo prevented all user_newtalk data from being generated
for logged in users. This broke the hasmsg API and also prevented
anyone from being able to implement client-side growlers or alerts
based on this data. The new approach is more conservative - it allows
updates to the user_newtalk table, but prevents the alert itself
(orange bar of doom) from being displayed to logged in users. This
will provide more flexibility for future development regarding talk
page alerts (both for extensions and gadgets).

Note: This change is dependant on the new core change I2105bdd2.

Bug: 47962
Change-Id: I3f35a56b3f1795c2b21a6e4af8fc93b5e61b7d3c
This commit is contained in:
kaldari 2013-05-04 17:49:08 -07:00
parent 82522e0573
commit e1e62e691c
2 changed files with 20 additions and 13 deletions

View file

@ -184,7 +184,7 @@ $wgHooks['UserSaveSettings'][] = 'EchoHooks::onUserSaveSettings';
$wgHooks['AbortEmailNotification'][] = 'EchoHooks::disableStandUserTalkEnotif';
$wgHooks['UpdateUserMailerFormattedPageStatus'][] = 'EchoHooks::disableStandUserTalkEnotif';
// Disable the yellow bar of death
$wgHooks['ArticleEditUpdateNewTalk'][] = 'EchoHooks::abortNewTalkNotification';
$wgHooks['GetNewMessagesAlert'][] = 'EchoHooks::abortNewMessagesAlert';
$wgHooks['LinksUpdateAfterInsert'][] = 'EchoHooks::onLinksUpdateAfterInsert';
// Configuration

View file

@ -667,25 +667,32 @@ class EchoHooks {
}
/**
* Handler for ArticleEditUpdateNewTalk hook.
* @see http://www.mediawiki.org/wiki/Manual:Hooks/ArticleEditUpdateNewTalk
* @param &$page WikiPage The WikiPage object of the talk page being updated
* @param $recipient User The user who's talk page was edited
* @return bool Should return false to prevent the orange notification bar
* or true to allow the orange notification bar
* Handler for GetNewMessagesAlert hook.
* We're using the GetNewMessagesAlert hook instead of the
* ArticleEditUpdateNewTalk hook since we still want the user_newtalk data
* to be updated and availble to client-side tools and the API.
* @see http://www.mediawiki.org/wiki/Manual:Hooks/GetNewMessagesAlert
* @param &$newMessagesAlert String An alert that the user has new messages
* or an empty string if the user does not (empty by default)
* @param $newtalks Array This will be empty if the user has no new messages
* or an Array containing links and revisions if there are new messages
* @param $user User The user who is loading the page
* @param $out Output object
* @return bool Should return false to prevent the new messages alert (OBOD)
* or true to allow the new messages alert
*/
static function abortNewTalkNotification( &$page, $recipient ) {
static function abortNewMessagesAlert( &$newMessagesAlert, $newtalks, $user, $out ) {
global $wgEchoNotifications;
// If the user has the notifications flyout turned on and is receiving
// notifications for talk page messages, disable the orange-bar-style notice.
if ( $recipient->isLoggedIn()
&& $recipient->getOption( 'echo-notify-show-link' )
// notifications for talk page messages, disable the new messages alert.
if ( $user->isLoggedIn()
&& $user->getOption( 'echo-notify-show-link' )
&& isset( $wgEchoNotifications['edit-user-talk'] )
) {
// hide orange bar
// hide new messages alert
return false;
} else {
// show orange bar
// show new messages alert
return true;
}
}