mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 07:54:13 +00:00
Merge "Introduce congratulatory notifications for reaching edit thresholds"
This commit is contained in:
commit
5019802f29
20
Echo.php
20
Echo.php
|
@ -175,6 +175,10 @@ $wgEchoDefaultNotificationTypes = array(
|
|||
'welcome' => array(
|
||||
'email' => false,
|
||||
),
|
||||
// … and for edit threshold events
|
||||
'thank-you-edit' => array(
|
||||
'email' => false,
|
||||
),
|
||||
// No need to get a email when another user sends to me
|
||||
'emailuser' => array(
|
||||
'web' => true,
|
||||
|
@ -275,6 +279,12 @@ $wgEchoNotificationIcons = array(
|
|||
'chat' => array(
|
||||
'path' => "$echoIconPath/chat.svg",
|
||||
),
|
||||
'edit' => array(
|
||||
'path' => array(
|
||||
'ltr' => "$echoIconPath/ooui-edit-ltr-progressive.svg",
|
||||
'rtl' => "$echoIconPath/ooui-edit-rtl-progressive.svg",
|
||||
),
|
||||
),
|
||||
'edit-user-talk' => array(
|
||||
'path' => "$echoIconPath/edit-user-talk.svg",
|
||||
),
|
||||
|
@ -457,6 +467,16 @@ $wgEchoNotifications = array(
|
|||
'section' => 'alert',
|
||||
'icon' => 'global',
|
||||
),
|
||||
'thank-you-edit' => array(
|
||||
'user-locators' => array(
|
||||
'EchoUserLocator::locateEventAgent'
|
||||
),
|
||||
'category' => 'system',
|
||||
'group' => 'positive',
|
||||
'presentation-model' => 'EchoEditThresholdPresentationModel',
|
||||
'section' => 'alert',
|
||||
'icon' => 'edit',
|
||||
),
|
||||
);
|
||||
|
||||
// Enable new talk page messages alert for all logged in users by default
|
||||
|
|
27
Hooks.php
27
Hooks.php
|
@ -438,16 +438,39 @@ class EchoHooks {
|
|||
if ( !$revision ) {
|
||||
return true;
|
||||
}
|
||||
$title = $article->getTitle();
|
||||
|
||||
// Try to do this after the HTTP response
|
||||
DeferredUpdates::addCallableUpdate( function () use ( $revision ) {
|
||||
EchoDiscussionParser::generateEventsForRevision( $revision );
|
||||
} );
|
||||
|
||||
// If the user is not an IP and this is not a null edit,
|
||||
// test for them reaching a congratulatory threshold
|
||||
$thresholds = array( 1, 10, 100, 1000 );
|
||||
if ( $user->isLoggedIn() && $status->value['revision'] ) {
|
||||
// This edit hasn't been added to the edit count yet
|
||||
$editCount = $user->getEditCount() + 1;
|
||||
if ( in_array( $editCount, $thresholds ) ) {
|
||||
DeferredUpdates::addCallableUpdate( function () use ( $user, $title, $editCount ) {
|
||||
EchoEvent::create( array(
|
||||
'type' => 'thank-you-edit',
|
||||
'title' => $title,
|
||||
'agent' => $user,
|
||||
// Edit threshold notifications are sent to the agent
|
||||
'extra' => array(
|
||||
'notifyAgent' => true,
|
||||
'editCount' => $editCount,
|
||||
)
|
||||
)
|
||||
);
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
// Handle the case of someone undoing an edit, either through the
|
||||
// 'undo' link in the article history or via the API.
|
||||
if ( isset( $wgEchoNotifications['reverted'] ) ) {
|
||||
$title = $article->getTitle();
|
||||
$undidRevId = $wgRequest->getVal( 'wpUndidRevision' );
|
||||
if ( $undidRevId ) {
|
||||
$undidRevision = Revision::newFromId( $undidRevId );
|
||||
|
@ -516,7 +539,7 @@ class EchoHooks {
|
|||
EchoEvent::create( array(
|
||||
'type' => 'welcome',
|
||||
'agent' => $user,
|
||||
// welcome email is sent to agent
|
||||
// Welcome notification is sent to the agent
|
||||
'extra' => array(
|
||||
'notifyAgent' => true
|
||||
)
|
||||
|
|
|
@ -33,6 +33,7 @@ $wgAutoloadClasses += array(
|
|||
'EchoDiscussionParser' => __DIR__ . '/includes/DiscussionParser.php',
|
||||
'EchoDiscussionParserTest' => __DIR__ . '/tests/phpunit/DiscussionParserTest.php',
|
||||
'EchoEditFormatter' => __DIR__ . '/includes/formatters/EditFormatter.php',
|
||||
'EchoEditThresholdPresentationModel' => __DIR__ . '/includes/formatters/EditThresholdPresentationModel.php',
|
||||
'EchoEditUserTalkFormatter' => __DIR__ . '/includes/formatters/EditUserTalkFormatter.php',
|
||||
'EchoEditUserTalkPresentationModel' => __DIR__ . '/includes/formatters/EditUserTalkPresentationModel.php',
|
||||
'EchoEmailDecorator' => __DIR__ . '/includes/EmailFormatter.php',
|
||||
|
|
|
@ -102,6 +102,11 @@
|
|||
"notification-header-welcome": "{{GENDER:$2|Welcome}} to {{SITENAME}}, $1! We're glad {{GENDER:$2|you're}} here.",
|
||||
"notification-welcome-link": "",
|
||||
"notification-welcome-linktext": "Welcome",
|
||||
"notification-header-thank-you-1-edit": "{{GENDER:$2|You}} just made {{GENDER:$2|your}} first edit to {{SITENAME}}; thank {{GENDER:$2|you}}, and welcome!",
|
||||
"notification-header-thank-you-10-edit": "{{GENDER:$2|You}} just made {{GENDER:$2|your}} tenth edit to {{SITENAME}}; thank {{GENDER:$2|you}}, and please keep going!",
|
||||
"notification-header-thank-you-100-edit": "{{GENDER:$2|You}} just made {{GENDER:$2|your}} hundredth edit to {{SITENAME}}; thank {{GENDER:$2|you}} very much!",
|
||||
"notification-header-thank-you-1000-edit": "{{GENDER:$2|You}} just made {{GENDER:$2|your}} thousandth edit to {{SITENAME}}; thank {{GENDER:$2|you}} for being a great contributor!",
|
||||
"notification-link-thank-you-edit": "{{GENDER:$1|Your}} edit",
|
||||
"notification-reverted2": "Your {{PLURAL:$4|edit on [[:$2]] has|edits on [[:$2]] have}} been {{GENDER:$1|reverted}} by [[$5|$1]]. $3",
|
||||
"notification-header-reverted": "Your {{PLURAL:$4|edit on '''$3''' was|edits on '''$3''' were}} {{GENDER:$2|reverted}}",
|
||||
"notification-body-reverted": "$1",
|
||||
|
|
|
@ -120,9 +120,14 @@
|
|||
"notification-header-user-rights-remove-only": "Notifications header message when a user is removed from groups. 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 that were removed\n* $3 - the number of groups that were removed, can be used for PLURAL\n* $4 - name of the user viewing the notification, can be used for GENDER",
|
||||
"notification-header-user-rights-add-and-remove": "Notifications header message when a user is added to groups and removed from groups. 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 that were added\n* $4 - a localized list of the groups that were removed\n* $6 - name of the user viewing the notification, can be used for GENDER",
|
||||
"notification-new-user": "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-welcome": "Text of the welcome notification. Parameters:\n* $1 - the name of the new user.Parameters:\n* $1 - the formatted username of the new user\n* $2 - the username for gender purposes\nSee also:\n* {{msg-mw|Guidedtour-tour-gettingstarted-start-title}}",
|
||||
"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-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",
|
||||
"notification-header-thank-you-10-edit": "Text of the editor welcome notification for their tenth edit.\nParameters:\n* $1 - the formatted username of the new user\n* $2 - the username for gender purposes",
|
||||
"notification-header-thank-you-100-edit": "Text of the editor welcome notification for their hundredth edit.\nParameters:\n* $1 - the formatted username of the new user\n* $2 - the username for gender purposes",
|
||||
"notification-header-thank-you-1000-edit": "Text of the editor welcome notification for their thousandth edit.\nParameters:\n* $1 - the formatted username of the new user\n* $2 - the username for gender purposes",
|
||||
"notification-link-thank-you-edit": "Label for the link to the user's edit which triggered a threshold congratulations message.\nParameters:\n* $1 - the username for gender purposes",
|
||||
"notification-reverted2": "Format for displaying notifications of a user's edit being reverted. Parameters:\n* $1 - the username of the person who reverted, plain text. Can be used for GENDER.\n* $2 - the page that was reverted, formatted\n* $3 - a diff link which is labeled {{msg-mw|Showdiff}}\n* $4 - the number of edits that were reverted. NOTE: This will only be set to 1 or 2, with 2 actually meaning 'an unknown number greater than 0'.\n* $5 - Page for reverting user.\nUser page if logged in, or user's contributions page if logged out.\n{{Related|Notification-reverted}}",
|
||||
"notification-header-reverted": "Notification header of a user's edit being reverted.\n\nParameters:\n* $1 - the formatted username of the person who reverted.\n* $2 - the username for GENDER\n* $3 - the page that was reverted, formatted\n* $4 - the number of edits that were reverted. NOTE: This will only be set to 1 or 2, with 2 actually meaning \"an unknown number greater than 0\".\n{{Related|Notification-reverted}}",
|
||||
"notification-body-reverted": "{{notranslate}}",
|
||||
|
|
19
includes/formatters/EditThresholdPresentationModel.php
Normal file
19
includes/formatters/EditThresholdPresentationModel.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
class EchoEditThresholdPresentationModel extends EchoEventPresentationModel {
|
||||
|
||||
public function getIconType() {
|
||||
return 'edit';
|
||||
}
|
||||
|
||||
public function getHeaderMessageKey() {
|
||||
return 'notification-header-thank-you-' . $this->event->getExtraParam( 'editCount' ) . '-edit';
|
||||
}
|
||||
|
||||
public function getPrimaryLink() {
|
||||
return array(
|
||||
'url' => $this->event->getTitle()->getLocalURL(),
|
||||
'label' => $this->msg( 'notification-link-thank-you-edit', $this->getViewingUserForGender() )->text()
|
||||
);
|
||||
}
|
||||
}
|
4
modules/icons/ooui-edit-ltr-progressive.svg
Normal file
4
modules/icons/ooui-edit-ltr-progressive.svg
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
||||
<path d="M17 2L5 14l-1 5 5-1L21 6c0-2-2-4-4-4zM7.2 15.5c-.3-.3-.7-.6-1-.8C8.5 12.4 17.5 3.3 17.5 3.3c.4.1.7.3 1 .7L7.2 15.5z" fill="#347bff"/>
|
||||
</svg>
|
After Width: | Height: | Size: 277 B |
4
modules/icons/ooui-edit-rtl-progressive.svg
Normal file
4
modules/icons/ooui-edit-rtl-progressive.svg
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
||||
<path d="M8 2l12 12 1 5-5-1L4 6c0-2 2-4 4-4zm9.8 13.5c.3-.3.7-.6 1-.8C16.5 12.4 7.5 3.3 7.5 3.3c-.4.1-.7.3-1 .7l11.3 11.5z" fill="#347bff"/>
|
||||
</svg>
|
After Width: | Height: | Size: 275 B |
Loading…
Reference in a new issue