mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-11 17:00:10 +00:00
Add support for watchlist events
Bug: T203941 Change-Id: I9bcd13cb0a547393696dde0e977b7761cc1fea68
This commit is contained in:
parent
259db7d3bf
commit
db78c1552e
|
@ -455,7 +455,8 @@
|
|||
"SendWatchlistEmailNotification": "EchoHooks::onSendWatchlistEmailNotification",
|
||||
"GetNewMessagesAlert": "EchoHooks::abortNewMessagesAlert",
|
||||
"LinksUpdateAfterInsert": "EchoHooks::onLinksUpdateAfterInsert",
|
||||
"SpecialMuteModifyFormFields": "EchoHooks::onSpecialMuteModifyFormFields"
|
||||
"SpecialMuteModifyFormFields": "EchoHooks::onSpecialMuteModifyFormFields",
|
||||
"RecentChange_save": "EchoHooks::onRecentChangeSave"
|
||||
},
|
||||
"config": {
|
||||
"EchoEnableEmailBatch": {
|
||||
|
@ -630,6 +631,14 @@
|
|||
"thank-you-edit": {
|
||||
"priority": 9,
|
||||
"tooltip": "echo-pref-tooltip-thank-you-edit"
|
||||
},
|
||||
"watchlist": {
|
||||
"priority": 5,
|
||||
"tooltip": "echo-pref-tooltip-watchlist"
|
||||
},
|
||||
"minor-watchlist": {
|
||||
"priority": 6,
|
||||
"tooltip": "echo-pref-tooltip-minor-watchlist"
|
||||
}
|
||||
},
|
||||
"merge_strategy": "array_plus_2d"
|
||||
|
@ -771,6 +780,32 @@
|
|||
"expandable": true
|
||||
}
|
||||
},
|
||||
"minor-watchlist-change": {
|
||||
"user-locators": [
|
||||
"EchoUserLocator::locateUsersWatchingTitle"
|
||||
],
|
||||
"category": "minor-watchlist",
|
||||
"group": "interactive",
|
||||
"presentation-model": "EchoWatchlistChangePresentationModel",
|
||||
"bundle": {
|
||||
"web": true,
|
||||
"email": true,
|
||||
"expandable": true
|
||||
}
|
||||
},
|
||||
"watchlist-change": {
|
||||
"user-locators": [
|
||||
"EchoUserLocator::locateUsersWatchingTitle"
|
||||
],
|
||||
"category": "watchlist",
|
||||
"group": "interactive",
|
||||
"presentation-model": "EchoWatchlistChangePresentationModel",
|
||||
"bundle": {
|
||||
"web": true,
|
||||
"email": true,
|
||||
"expandable": true
|
||||
}
|
||||
},
|
||||
"mention": {
|
||||
"user-locators": [
|
||||
[
|
||||
|
@ -934,6 +969,14 @@
|
|||
"EchoPollForUpdates": {
|
||||
"value": 0,
|
||||
"description": "This is the polling rate i.e. the time after which we check for notifications count on the client side. It also controls whether notification count will be displayed in browser title. If polling rate is 0 this means polling is disabled and notification count is also not shown in browser title"
|
||||
},
|
||||
"EchoWatchlistNotifications": {
|
||||
"value": false,
|
||||
"description": "Feature flag to enable Echo notifications whenever a page on a user's watchlist is changed, replacing the built-in preference to send emails in that circumstance."
|
||||
},
|
||||
"EchoWatchlistEmailOncePerPage": {
|
||||
"value": true,
|
||||
"description": "Whether to send email notifications each time a watched page is edited (if false) or only the first time the page is changed before being visited again by the user (if true)"
|
||||
}
|
||||
},
|
||||
"attributes": {
|
||||
|
@ -1025,6 +1068,7 @@
|
|||
"EchoUserNotificationGateway": "includes/gateway/UserNotificationGateway.php",
|
||||
"EchoUserRightsPresentationModel": "includes/formatters/UserRightsPresentationModel.php",
|
||||
"EchoWelcomePresentationModel": "includes/formatters/WelcomePresentationModel.php",
|
||||
"EchoWatchlistChangePresentationModel": "includes/formatters/WatchlistChangePresentationModel.php",
|
||||
"GenerateSampleNotifications": "maintenance/generateSampleNotifications.php",
|
||||
"MWEchoDbFactory": "includes/EchoDbFactory.php",
|
||||
"MWEchoEmailBatch": "includes/EmailBatch.php",
|
||||
|
|
14
i18n/en.json
14
i18n/en.json
|
@ -75,6 +75,8 @@
|
|||
"echo-category-title-emailuser": "{{PLURAL:$1|Email from other user|Emails from other users}}",
|
||||
"echo-category-title-article-reminder": "Page {{PLURAL:$1|reminder|reminders}}",
|
||||
"echo-category-title-thank-you-edit": "Edit {{PLURAL:$1|milestone|milestones}}",
|
||||
"echo-category-title-watchlist": "Edit to watched page",
|
||||
"echo-category-title-minor-watchlist": "Minor edit to watched page",
|
||||
"echo-pref-tooltip-edit-user-talk": "Notify me when someone posts a message or replies on my talk page.",
|
||||
"echo-pref-tooltip-article-linked": "Notify me when someone links to a page I created from another page.",
|
||||
"echo-pref-tooltip-reverted": "Notify me when someone reverts an edit I made, by using the undo or rollback tool.",
|
||||
|
@ -85,6 +87,8 @@
|
|||
"echo-pref-tooltip-emailuser": "Notify me when someone sends me an email.",
|
||||
"echo-pref-tooltip-article-reminder": "Notify me about this page when I ask.",
|
||||
"echo-pref-tooltip-thank-you-edit": "Notify me when I reach my 1st, 10th, 100th... edit.",
|
||||
"echo-pref-tooltip-watchlist": "Notify me when someone makes a (non-minor) edit to a page on my watchlist.",
|
||||
"echo-pref-tooltip-minor-watchlist": "Notify me when someone makes a minor edit to a page on my watchlist.",
|
||||
"notifications": "Notifications",
|
||||
"tooltip-pt-notifications-alert": "{{GENDER:|Your}} alerts",
|
||||
"tooltip-pt-notifications-notice": "{{GENDER:|Your}} notices",
|
||||
|
@ -171,6 +175,16 @@
|
|||
"notification-header-user-rights-expiry-change": "The expiry of {{GENDER:$4|your}} membership in the following {{PLURAL:$3|group|groups}} has been {{GENDER:$1|changed}}: $2.",
|
||||
"notification-header-welcome": "{{GENDER:$2|Welcome}} to {{SITENAME}}, $1! We're glad {{GENDER:$2|you're}} here.",
|
||||
"notification-header-mention-summary": "$1 {{GENDER:$2|mentioned}} {{GENDER:$3|you}} in an edit summary on <strong>$4</strong>.",
|
||||
"notification-header-watchlist-changed": "$1 {{GENDER:$2|changed}} <strong>$3</strong>, a page on {{GENDER:$4|your}} watchlist{{PLURAL:$5||, $5 times}}.",
|
||||
"notification-header-watchlist-created": "$1 {{GENDER:$2|created}} <strong>$3</strong>, a page on {{GENDER:$4|your}} watchlist{{PLURAL:$5||, $5 times}}.",
|
||||
"notification-header-watchlist-deleted": "$1 {{GENDER:$2|deleted}} <strong>$3</strong>, a page on {{GENDER:$4|your}} watchlist{{PLURAL:$5||, $5 times}}.",
|
||||
"notification-header-watchlist-moved": "$1 {{GENDER:$2|moved}} <strong>$3</strong>, a page on {{GENDER:$4|your}} watchlist{{PLURAL:$5||, $5 times}}.",
|
||||
"notification-header-watchlist-restored": "$1 {{GENDER:$2|restored}} <strong>$3</strong>, a page on {{GENDER:$4|your}} watchlist{{PLURAL:$5||, $5 times}}.",
|
||||
"notification-header-watchlist-multiuser-changed": "<strong>$1</strong>, a page on {{GENDER:$2|your}} watchlist, was changed $3 times.",
|
||||
"notification-header-watchlist-multiuser-created": "<strong>$1</strong>, a page on {{GENDER:$2|your}} watchlist, was created $3 times.",
|
||||
"notification-header-watchlist-multiuser-deleted": "<strong>$1</strong>, a page on {{GENDER:$2|your}} watchlist, was deleted $3 times.",
|
||||
"notification-header-watchlist-multiuser-moved": "<strong>$1</strong>, a page on {{GENDER:$2|your}} watchlist, was moved $3 times.",
|
||||
"notification-header-watchlist-multiuser-restored": "<strong>$1</strong>, a page on {{GENDER:$2|your}} watchlist, was restored $3 times.",
|
||||
"notification-welcome-link": "",
|
||||
"notification-welcome-linktext": "Welcome",
|
||||
"notification-header-thank-you-1-edit": "{{GENDER:$2|You}} just made {{GENDER:$2|your}} first edit; thank {{GENDER:$2|you}}, and welcome!",
|
||||
|
|
|
@ -75,6 +75,8 @@
|
|||
"echo-category-title-emailuser": "{{doc-echo-category-title|tooltip=Echo-pref-tooltip-emailuser}}",
|
||||
"echo-category-title-article-reminder": "{{doc-echo-category-title|tooltip=Echo-pref-tooltip-article-reminder}}",
|
||||
"echo-category-title-thank-you-edit": "'''Note that this doesn't mean \"to edit milestones\", but \"milestones of editing\".'''\n\n{{doc-echo-category-title|tooltip=Echo-pref-tooltip-thank-you-edit}}",
|
||||
"echo-category-title-watchlist":"{{doc-echo-category-title|tooltip=Echo-pref-tooltip-watchlist}}",
|
||||
"echo-category-title-minor-watchlist":"{{doc-echo-category-title|tooltip=Echo-pref-tooltip-minor-watchlist}}",
|
||||
"echo-pref-tooltip-edit-user-talk": "{{doc-echo-pref-tooltip|title=Echo-category-title-edit-user-talk}}",
|
||||
"echo-pref-tooltip-article-linked": "{{doc-echo-pref-tooltip|title=Echo-category-title-article-linked}}",
|
||||
"echo-pref-tooltip-reverted": "{{doc-echo-pref-tooltip|title=Echo-category-title-reverted}}",
|
||||
|
@ -85,6 +87,8 @@
|
|||
"echo-pref-tooltip-emailuser": "{{doc-echo-pref-tooltip|title=Echo-category-title-emailuser}}",
|
||||
"echo-pref-tooltip-article-reminder": "{{doc-echo-pref-tooltip|title=Echo-category-title-article-reminder}}",
|
||||
"echo-pref-tooltip-thank-you-edit": "{{doc-echo-pref-tooltip|title=Echo-category-title-thank-you-edit}}",
|
||||
"echo-pref-tooltip-watchlist": "{{doc-echo-pref-tooltip|title=Echo-category-title-watchlist}}",
|
||||
"echo-pref-tooltip-minor-watchlist": "{{doc-echo-pref-tooltip|title=Echo-category-title-minor-watchlist}}",
|
||||
"notifications": "{{doc-special|Notifications}}\n{{Identical|Notification}}",
|
||||
"tooltip-pt-notifications-alert": "This is used for the title (mouseover text) of the alert notifications user tool.",
|
||||
"tooltip-pt-notifications-notice": "This is used for the title (mouseover text) of the notice notifications user tool.",
|
||||
|
@ -171,6 +175,16 @@
|
|||
"notification-header-user-rights-expiry-change": "Notifications header message when a user's group membership is extended or reduced in duration. Parameters:\n* $1 - the raw username of the person who made the user rights change, can be used for GENDER support\n* $2 - a localized list of the groups for which the expiry was changed\n* $3 - the number of groups that were changed, can be used for PLURAL\n* $4 - name of the user viewing the notification, can be used for GENDER",
|
||||
"notification-header-welcome": "Text of the welcome notification. Parameters:\n* $1 - the name of the new user.\nSee also:\n* {{msg-mw|Guidedtour-tour-gettingstarted-start-title}}",
|
||||
"notification-header-mention-summary": "Header text for a notification when you are mentioned by another user in an edit summary.\n* $1 - user's name (not suitable for GENDER).\n* $2 - user's name for use in GENDER.\n* $3 - name of the user viewing the notification, can be used for GENDER\n* $4 - name of the page they were mentioned in (with namespace)",
|
||||
"notification-header-watchlist-changed": "Text of a notification when another user changes a page on your watchlist.\n* $1 - user's name (not suitable for GENDER).\n* $2 - user's name for use in GENDER.\n* $3 - name of the page that was changed (with namespace) \n * $4 - name of the user viewing the notification, can be used for GENDER \n* $5 - Number of times the page has been changed.",
|
||||
"notification-header-watchlist-created": "Text of a notification when another user creates a page on your watchlist.\n* $1 - user's name (not suitable for GENDER).\n* $2 - user's name for use in GENDER.\n* $3 - name of the page that was created (with namespace) \n * $4 - name of the user viewing the notification, can be used for GENDER \n* $5 - Number of times the page has been created.",
|
||||
"notification-header-watchlist-deleted": "Text of a notification when another user deletes a page on your watchlist.\n* $1 - user's name (not suitable for GENDER).\n* $2 - user's name for use in GENDER.\n* $3 - name of the page that was deleted (with namespace)) \n * $4 - name of the user viewing the notification, can be used for GENDER \n* $5 - Number of times the page has been deleted.",
|
||||
"notification-header-watchlist-moved": "Text of a notification when another user moves a page on your watchlist.\n* $1 - user's name (not suitable for GENDER).\n* $2 - user's name for use in GENDER.\n* $3 - name of the page that was moved (with namespace) \n * $4 - name of the user viewing the notification, can be used for GENDER \n* $5 - Number of times the page has been moved.",
|
||||
"notification-header-watchlist-restored": "Text of a notification when another user restores a page on your watchlist.\n* $1 - user's name (not suitable for GENDER).\n* $2 - user's name for use in GENDER.\n* $3 - name of the page that was restored (with namespace) \n * $4 - name of the user viewing the notification, can be used for GENDER \n* $5 - Number of times the page has been restored.",
|
||||
"notification-header-watchlist-multiuser-changed": "Text of a notification when multiple different users change pages on your watchlist.\n* $1 - name of the page that was changed (with namespace) \n * $2 - name of the user viewing the notification, can be used for GENDER \n* $3 - Number of times the page has been changed. (Always greater than one).",
|
||||
"notification-header-watchlist-multiuser-created": "Text of a notification when multiple different users create pages on your watchlist.\n* $1 - name of the page that was created (with namespace) \n * $2 - name of the user viewing the notification, can be used for GENDER \n* $3 - Number of times the page has been created. (Always greater than one)",
|
||||
"notification-header-watchlist-multiuser-deleted": "Text of a notification when multiple different users move pages on your watchlist.\n* $1 - name of the page that was deleted (with namespace) \n * $2 - name of the user viewing the notification, can be used for GENDER \n* $3 - Number of times the page has been deleted. (Always greater than one)",
|
||||
"notification-header-watchlist-multiuser-moved": "Text of a notification when multiple different users move pages on your watchlist.\n* $1 - name of the page that was moved (with namespace) \n * $2 - name of the user viewing the notification, can be used for GENDER \n* $3 - Number of times the page has been moved. (Always greater than one)",
|
||||
"notification-header-watchlist-multiuser-restored": "Text of a notification when multiple different users restore pages on your watchlist.\n* $1 - name of the page that was restored (with namespace) \n * $2 - name of the user viewing the notification, can be used for GENDER \n* $3 - Number of times the page has been restored. (Always greater than one)",
|
||||
"notification-welcome-link": "{{notranslate}}",
|
||||
"notification-welcome-linktext": "Link text for link to the wiki's welcome or introduction page.\n{{Identical|Welcome}}",
|
||||
"notification-header-thank-you-1-edit": "Text of the editor welcome notification for their first edit.\nParameters:\n* $1 - the formatted username of the new user\n* $2 - the username for gender purposes",
|
||||
|
|
|
@ -47,6 +47,12 @@ class EchoHooks {
|
|||
'mention-success' => [
|
||||
'web' => false,
|
||||
],
|
||||
'watchlist' => [
|
||||
'web' => false,
|
||||
],
|
||||
'minor-watchlist' => [
|
||||
'web' => false,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ( $wgEchoNotificationCategories as $category => $categoryData ) {
|
||||
|
@ -68,7 +74,7 @@ class EchoHooks {
|
|||
public static function initEchoExtension() {
|
||||
global $wgEchoNotifications, $wgEchoNotificationCategories, $wgEchoNotificationIcons,
|
||||
$wgEchoMentionStatusNotifications, $wgAllowArticleReminderNotification, $wgAPIModules,
|
||||
$wgEchoSeenTimeCacheType, $wgMainStash;
|
||||
$wgEchoWatchlistNotifications, $wgEchoSeenTimeCacheType, $wgMainStash;
|
||||
|
||||
// allow extensions to define their own event
|
||||
Hooks::run( 'BeforeCreateEchoEvent',
|
||||
|
@ -86,6 +92,12 @@ class EchoHooks {
|
|||
unset( $wgAPIModules['echoarticlereminder'] );
|
||||
}
|
||||
|
||||
// Only allow watchlist notifications when enabled
|
||||
if ( !$wgEchoWatchlistNotifications ) {
|
||||
unset( $wgEchoNotificationCategories['watchlist'] );
|
||||
unset( $wgEchoNotificationCategories['minor-watchlist'] );
|
||||
}
|
||||
|
||||
// Default $wgEchoSeenTimeCacheType to $wgMainStash
|
||||
if ( $wgEchoSeenTimeCacheType === null ) {
|
||||
$wgEchoSeenTimeCacheType = $wgMainStash;
|
||||
|
@ -284,6 +296,14 @@ class EchoHooks {
|
|||
case 'mention-failure':
|
||||
$bundleString = 'mention-status-' . $event->getExtraParam( 'revid' );
|
||||
break;
|
||||
case 'watchlist-change':
|
||||
case 'minor-watchlist-change':
|
||||
$bundleString = 'watchlist-change';
|
||||
if ( $event->getTitle() ) {
|
||||
$bundleString .= '-' . $event->getTitle()->getNamespace()
|
||||
. '-' . $event->getTitle()->getDBkey();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -303,7 +323,8 @@ class EchoHooks {
|
|||
global $wgEchoEnableEmailBatch,
|
||||
$wgEchoNotifiers, $wgEchoNotificationCategories, $wgEchoNotifications,
|
||||
$wgAllowHTMLEmail, $wgEchoPollForUpdates,
|
||||
$wgEchoCrossWikiNotifications, $wgEchoPerUserBlacklist;
|
||||
$wgEchoCrossWikiNotifications, $wgEchoPerUserBlacklist,
|
||||
$wgEchoWatchlistNotifications;
|
||||
|
||||
$attributeManager = EchoAttributeManager::newFromGlobalVars();
|
||||
|
||||
|
@ -382,10 +403,11 @@ class EchoHooks {
|
|||
asort( $categoriesAndPriorities );
|
||||
$validSortedCategories = array_keys( $categoriesAndPriorities );
|
||||
|
||||
// Show subscription options. IMPORTANT: 'echo-subscriptions-email-edit-user-talk' is a
|
||||
// virtual option, its value is saved to existing talk page notification option
|
||||
// 'enotifusertalkpages', see onUserLoadOptions() and onUserSaveOptions() for more
|
||||
// information on how it is handled. Doing it in this way, we can avoid keeping running
|
||||
// Show subscription options. IMPORTANT: 'echo-subscriptions-email-edit-user-talk',
|
||||
// 'echo-subscriptions-email-watchlist', and 'echo-subscriptions-email-minor-watchlist' are
|
||||
// virtual options, their values are saved to existing notification options 'enotifusertalkpages',
|
||||
// 'enotifwatchlistpages', and 'enotifminoredits', see onUserLoadOptions() and onUserSaveOptions()
|
||||
// for more information on how it is handled. Doing it in this way, we can avoid keeping running
|
||||
// massive data migration script to keep these two options synced when echo is enabled on
|
||||
// new wikis or Echo is disabled and re-enabled for some reason. We can update the name
|
||||
// if Echo is ever merged to core
|
||||
|
@ -458,17 +480,23 @@ class EchoHooks {
|
|||
];
|
||||
}
|
||||
|
||||
// If we're using Echo to handle user talk page post notifications,
|
||||
// hide the old (non-Echo) preference for this. If Echo is moved to core
|
||||
// we'll want to remove this old user option entirely. For now, though,
|
||||
// If we're using Echo to handle user talk page post or watchlist notifications,
|
||||
// hide the old (non-Echo) preferences for them. If Echo is moved to core
|
||||
// we'll want to remove the old user options entirely. For now, though,
|
||||
// we need to keep it defined in case Echo is ever uninstalled.
|
||||
// Otherwise, that preference could be lost entirely. This hiding logic
|
||||
// is not abstracted since there is only a single preference in core
|
||||
// that is potentially made obsolete by Echo.
|
||||
// is not abstracted since there are only three preferences in core
|
||||
// that are potentially made obsolete by Echo.
|
||||
if ( isset( $wgEchoNotifications['edit-user-talk'] ) ) {
|
||||
$preferences['enotifusertalkpages']['type'] = 'hidden';
|
||||
unset( $preferences['enotifusertalkpages']['section'] );
|
||||
}
|
||||
if ( $wgEchoWatchlistNotifications && isset( $wgEchoNotifications['watchlist-change'] ) ) {
|
||||
$preferences['enotifwatchlistpages']['type'] = 'hidden';
|
||||
unset( $preferences['enotifusertalkpages']['section'] );
|
||||
$preferences['enotifminoredits']['type'] = 'hidden';
|
||||
unset( $preferences['enotifminoredits']['section'] );
|
||||
}
|
||||
|
||||
if ( $wgEchoPerUserBlacklist ) {
|
||||
$preferences['echo-notifications-blacklist'] = [
|
||||
|
@ -636,7 +664,9 @@ class EchoHooks {
|
|||
* @return bool true - send email, false - do not send email
|
||||
*/
|
||||
public static function onEchoAbortEmailNotification( $user, $event ) {
|
||||
if ( $event->getType() === 'edit-user-talk' ) {
|
||||
global $wgEchoWatchlistEmailOncePerPage;
|
||||
$type = $event->getType();
|
||||
if ( $type === 'edit-user-talk' ) {
|
||||
$extra = $event->getExtra();
|
||||
if ( !empty( $extra['minoredit'] ) ) {
|
||||
global $wgEnotifMinorEdits;
|
||||
|
@ -645,9 +675,23 @@ class EchoHooks {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
// Mimic core code of only sending watchlist notification emails once per page
|
||||
} elseif ( $type === "watchlist-change" || $type === "minor-watchlist-change" ) {
|
||||
if ( !$wgEchoWatchlistEmailOncePerPage ) {
|
||||
// Don't care about rate limiting
|
||||
return true;
|
||||
}
|
||||
$store = MediaWikiServices::getInstance()->getWatchedItemStore();
|
||||
$ts = $store->getWatchedItem( $user, $event->getTitle() )->getNotificationTimestamp();
|
||||
// if (ts != null) is not sufficient because, if $wgEchoUseJobQueue is set,
|
||||
// wl_notificationtimestamp will have already been set for the new edit
|
||||
// by the time this code runs.
|
||||
if ( $ts !== null && $ts !== $event->getExtraParam( "timestamp" ) ) {
|
||||
// User has already seen an email for this page before
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Proceed to send talk page notification email
|
||||
// Proceed to send notification email
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1175,6 +1219,11 @@ class EchoHooks {
|
|||
* @return bool
|
||||
*/
|
||||
public static function onSendWatchlistEmailNotification( $targetUser, $title, $emailNotification ) {
|
||||
global $wgEchoNotifications, $wgEchoWatchlistNotifications;
|
||||
if ( $wgEchoWatchlistNotifications && isset( $wgEchoNotifications["watchlist-change"] ) ) {
|
||||
// Let echo handle watchlist notifications entirely
|
||||
return false;
|
||||
}
|
||||
// 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 ) ) {
|
||||
|
@ -1300,11 +1349,24 @@ class EchoHooks {
|
|||
* @return bool true in all cases
|
||||
*/
|
||||
public static function onUserLoadOptions( $user, &$options ) {
|
||||
global $wgEchoWatchlistNotifications;
|
||||
// Use existing enotifusertalkpages option for echo-subscriptions-email-edit-user-talk
|
||||
if ( isset( $options['enotifusertalkpages'] ) ) {
|
||||
$options['echo-subscriptions-email-edit-user-talk'] = $options['enotifusertalkpages'];
|
||||
}
|
||||
|
||||
if ( $wgEchoWatchlistNotifications ) {
|
||||
// Use existing enotifwatchlistpages option for echo-subscriptions-email-watchlist
|
||||
if ( isset( $options['enotifwatchlistpages'] ) ) {
|
||||
$options['echo-subscriptions-email-watchlist'] = $options['enotifwatchlistpages'];
|
||||
}
|
||||
|
||||
// Use existing enotifminoredits option for echo-subscriptions-email-minor-watchlist
|
||||
if ( isset( $options['enotifminoredits'] ) ) {
|
||||
$options['echo-subscriptions-email-minor-watchlist'] = $options['enotifminoredits'];
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1316,12 +1378,22 @@ class EchoHooks {
|
|||
* @return bool true in all cases
|
||||
*/
|
||||
public static function onUserSaveOptions( $user, &$options ) {
|
||||
// echo-subscriptions-email-edit-user-talk is just a virtual option,
|
||||
// save the value in the real option enotifusertalkpages
|
||||
global $wgEchoWatchlistNotifications;
|
||||
// save virtual option values in corresponding real option values
|
||||
if ( isset( $options['echo-subscriptions-email-edit-user-talk'] ) ) {
|
||||
$options['enotifusertalkpages'] = $options['echo-subscriptions-email-edit-user-talk'];
|
||||
unset( $options['echo-subscriptions-email-edit-user-talk'] );
|
||||
}
|
||||
if ( $wgEchoWatchlistNotifications ) {
|
||||
if ( isset( $options['echo-subscriptions-email-watchlist'] ) ) {
|
||||
$options['enotifwatchlistpages'] = $options['echo-subscriptions-email-watchlist'];
|
||||
unset( $options['echo-subscriptions-email-watchlist'] );
|
||||
}
|
||||
if ( isset( $options['echo-subscriptions-email-minor-watchlist'] ) ) {
|
||||
$options['enotifminoredits'] = $options['echo-subscriptions-email-minor-watchlist'];
|
||||
unset( $options['echo-subscriptions-email-minor-watchlist'] );
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1602,4 +1674,32 @@ class EchoHooks {
|
|||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for RecentChange_save hook
|
||||
*
|
||||
* @param RecentChange $change The change that has just been made to the wiki
|
||||
*/
|
||||
public static function onRecentChangeSave( RecentChange $change ) {
|
||||
global $wgEchoWatchlistNotifications;
|
||||
if ( !$wgEchoWatchlistNotifications ) {
|
||||
return;
|
||||
}
|
||||
if ( $change->getAttribute( 'rc_minor' ) ) {
|
||||
$type = 'minor-watchlist-change';
|
||||
} else {
|
||||
$type = 'watchlist-change';
|
||||
}
|
||||
EchoEvent::create( [
|
||||
'type' => $type,
|
||||
'title' => $change->getTitle(),
|
||||
'extra' => [
|
||||
'revid' => $change->getAttribute( "rc_this_oldid" ),
|
||||
'logid' => $change->getAttribute( "rc_logid" ),
|
||||
'status' => $change->mExtra["pageStatus"],
|
||||
'timestamp' => $change->getAttribute( "rc_timestamp" )
|
||||
],
|
||||
'agent' => $change->getPerformer()
|
||||
] );
|
||||
}
|
||||
}
|
||||
|
|
101
includes/formatters/WatchlistChangePresentationModel.php
Normal file
101
includes/formatters/WatchlistChangePresentationModel.php
Normal file
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
|
||||
class EchoWatchlistChangePresentationModel extends EchoEventPresentationModel {
|
||||
|
||||
public function getIconType() {
|
||||
// @todo create an icon to use here
|
||||
return 'placeholder';
|
||||
}
|
||||
|
||||
public function getHeaderMessage() {
|
||||
if ( $this->isMultiTypeBundle() ) {
|
||||
$status = "changed";
|
||||
} else {
|
||||
$status = $this->event->getExtraParam( 'status' );
|
||||
}
|
||||
if ( $this->isMultiUserBundle() ) {
|
||||
// Messages: notification-header-watchlist-multiuser-changed,
|
||||
// notification-header-watchlist-multiuser-created
|
||||
// notification-header-watchlist-multiuser-deleted
|
||||
// notification-header-watchlist-multiuser-moved
|
||||
// notification-header-watchlist-multiuser-restored
|
||||
$msg = $this->msg( "notification-header-watchlist-multiuser-" . $status );
|
||||
} else {
|
||||
// Messages: notification-header-watchlist-changed,
|
||||
// notification-header-watchlist-created
|
||||
// notification-header-watchlist-deleted
|
||||
// notification-header-watchlist-moved
|
||||
// notification-header-watchlist-restored
|
||||
$msg = $this->getMessageWithAgent( "notification-header-watchlist-" . $status );
|
||||
}
|
||||
$msg->params( $this->getTruncatedTitleText( $this->event->getTitle() ) );
|
||||
$msg->params( $this->getViewingUserForGender() );
|
||||
$msg->numParams( $this->getBundleCount() );
|
||||
return $msg;
|
||||
}
|
||||
|
||||
public function getPrimaryLink() {
|
||||
if ( $this->isBundled() ) {
|
||||
return [
|
||||
'url' => $this->event->getTitle()->getLocalUrl(),
|
||||
'label' => $this->msg( 'notification-link-text-view-page' )->text()
|
||||
];
|
||||
}
|
||||
return [
|
||||
'url' => $this->getViewChangesUrl(),
|
||||
'label' => $this->msg( 'notification-link-text-view-changes', $this->getViewingUserForGender() )->text(),
|
||||
];
|
||||
}
|
||||
|
||||
public function getSecondaryLinks() {
|
||||
if ( $this->isBundled() ) {
|
||||
if ( $this->isMultiUserBundle() ) {
|
||||
return [];
|
||||
} else {
|
||||
return [ $this->getAgentLink() ];
|
||||
}
|
||||
} else {
|
||||
$viewChangesLink = [
|
||||
'url' => $this->getViewChangesUrl(),
|
||||
'label' => $this->msg( 'notification-link-text-view-changes', $this->getViewingUserForGender() )->text(),
|
||||
'description' => '',
|
||||
'icon' => 'changes',
|
||||
'prioritized' => true,
|
||||
];
|
||||
return [ $this->getAgentLink(), $viewChangesLink ];
|
||||
}
|
||||
}
|
||||
|
||||
private function isMultiUserBundle() {
|
||||
foreach ( $this->getBundledEvents() as $bundled ) {
|
||||
if ( !$bundled->getAgent()->equals( $this->event->getAgent() ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function isMultiTypeBundle() {
|
||||
foreach ( $this->getBundledEvents() as $bundled ) {
|
||||
if ( $bundled->getExtraParam( 'status' ) !== $this->event->getExtraParam( 'status' ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function getViewChangesUrl() {
|
||||
$revid = $this->event->getExtraParam( 'revid' );
|
||||
if ( $revid === 0 ) {
|
||||
$url = SpecialPage::getTitleFor( 'Log' )->getLocalUrl( [
|
||||
'logid' => $this->event->getExtraParam( 'logid' )
|
||||
] );
|
||||
} else {
|
||||
$url = $this->event->getTitle()->getLocalURL( [
|
||||
'oldid' => 'prev',
|
||||
'diff' => $revid
|
||||
] );
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
}
|
|
@ -67,10 +67,12 @@ class EchoTalkPageFunctionalTest extends ApiTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return \stdClass[] All events in db sorted from oldest to newest
|
||||
* @return \stdClass[] All non-watchlist events in db sorted from oldest to newest
|
||||
*/
|
||||
protected function fetchAllEvents() {
|
||||
$res = $this->db->select( 'echo_event', EchoEvent::selectFields(), [], __METHOD__, [ 'ORDER BY' => 'event_id ASC' ] );
|
||||
$res = $this->db->select( 'echo_event', EchoEvent::selectFields(), [
|
||||
'event_type != "watchlist-change"'
|
||||
], __METHOD__, [ 'ORDER BY' => 'event_id ASC' ] );
|
||||
|
||||
return iterator_to_array( $res );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue