mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Thanks
synced 2024-11-15 02:54:23 +00:00
Better message when thanking on page creation
Add a new "revcreation" extra param to the stored echo event, that is set to "true" if it's a page creation. Create notification-header-creation-thank message. Bug: T201507 Change-Id: I80b206b1d24d53c9a60725bc25318e31f083aef0
This commit is contained in:
parent
214cebfb68
commit
801eed16b9
|
@ -34,6 +34,7 @@
|
|||
"echo-category-title-edit-thank": "Thanks",
|
||||
"notification-thanks-diff-link": "your edit",
|
||||
"notification-header-rev-thank": "$1 {{GENDER:$2|thanked}} {{GENDER:$4|you}} for your edit on <strong>$3</strong>.",
|
||||
"notification-header-creation-thank": "$1 {{GENDER:$2|thanked}} {{GENDER:$4|you}} for your creation of <strong>$3</strong>.",
|
||||
"notification-header-log-thank": "$1 {{GENDER:$2|thanked}} {{GENDER:$4|you}} for your action relating to <strong>$3</strong>.",
|
||||
"notification-compact-header-edit-thank": "$1 {{GENDER:$2|thanked}} {{GENDER:$3|you}}.",
|
||||
"notification-bundle-header-rev-thank": "{{PLURAL:$1|One person|$1 people|100=99+ people}} thanked {{GENDER:$3|you}} for your edit on <strong>$2</strong>.",
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
"echo-category-title-edit-thank": "{{doc-echo-category-title|tooltip=Echo-pref-tooltip-edit-thank}}\n{{Identical|Thank}}",
|
||||
"notification-thanks-diff-link": "The text of a link to the user's edit.\n\nUsed for <code>$2</code> in {{msg-mw|Notification-thanks}}. Should have capitalization appropriate for the middle of a sentence.\n\nThis is an object in a sentence so it should be in object case in languages where there is a special object form for words.",
|
||||
"notification-header-rev-thank": "Header text for a notification when a user is thanked for their edit. Parameters:\n* $1 is the username of the user sending the thanks (not suitable for GENDER).\n* $2 is the thanking user's name for use in GENDER.\n* $3 is the title of the page the thanked user edited.\n* $4 is the username of the user being thanked, for use in GENDER.",
|
||||
"notification-header-creation-thank": "Header text for a notification when a user is thanked for their creation of a page. Parameters:\n* $1 is the username of the user sending the thanks (not suitable for GENDER).\n* $2 is the thanking user's name for use in GENDER.\n* $3 is the title of the page the thanked user created.\n* $4 is the username of the user being thanked, for use in GENDER.",
|
||||
"notification-header-log-thank": "Header text for a notification when a user is thanked for a log entry. Parameters:\n* $1 is the username of the user sending the thanks (not suitable for GENDER).\n* $2 is the thanking user's name for use in GENDER.\n* $3 is the title of the page that is the target of the log entry.\n* $4 is the username of the user being thanked, for use in GENDER.",
|
||||
"notification-compact-header-edit-thank": "Compact header text for a notification when a user is thanked for their edit. Parameters:\n* $1 is the username of the user sending the thanks (not suitable for GENDER).\n* $2 is the thanking user's name for use in GENDER.\n* $3 is the username of the user being thanked, for use in GENDER.",
|
||||
"notification-bundle-header-rev-thank": "Bundle header text for a notification when a user is thanked for their edit. Parameters:\n* $1 is the number of users who sent thanks for the same edit. When used with PLURAL, the value 100 represents more than 99.\n* $2 is the title of the page the thanked user edited.\n* $3 is the username of the user being thanked, for use in GENDER.\n{{Related|Notification-bundle}}",
|
||||
|
|
|
@ -16,6 +16,7 @@ class ApiCoreThank extends ApiThank {
|
|||
$user = $this->getUser();
|
||||
$this->dieOnBadUser( $user );
|
||||
$params = $this->extractRequestParams();
|
||||
$revcreation = false;
|
||||
|
||||
$this->requireOnlyOneParameter( $params, 'rev', 'log' );
|
||||
|
||||
|
@ -50,6 +51,11 @@ class ApiCoreThank extends ApiThank {
|
|||
$title = $this->getTitleFromRevision( $revision );
|
||||
$recipient = $this->getUserFromRevision( $revision );
|
||||
$recipientUsername = $revision->getUserText();
|
||||
|
||||
// If there is no parent revid of this revision, it's a page creation.
|
||||
if ( !(bool)$revision->getPrevious() ) {
|
||||
$revcreation = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Send thanks.
|
||||
|
@ -64,7 +70,8 @@ class ApiCoreThank extends ApiThank {
|
|||
$excerpt,
|
||||
$recipient,
|
||||
$this->getSourceFromParams( $params ),
|
||||
$title
|
||||
$title,
|
||||
$revcreation
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -170,9 +177,10 @@ class ApiCoreThank extends ApiThank {
|
|||
* @param User $recipient The recipient of the thanks.
|
||||
* @param string $source Where the thanks was given.
|
||||
* @param Title $title The title of the page for which thanks is given.
|
||||
* @param bool $revcreation True if the linked revision is a page creation.
|
||||
*/
|
||||
protected function sendThanks(
|
||||
User $user, $type, $id, $excerpt, User $recipient, $source, Title $title
|
||||
User $user, $type, $id, $excerpt, User $recipient, $source, Title $title, $revcreation
|
||||
) {
|
||||
$uniqueId = $type . '-' . $id;
|
||||
// Do one last check to make sure we haven't sent Thanks before
|
||||
|
@ -191,6 +199,7 @@ class ApiCoreThank extends ApiThank {
|
|||
'thanked-user-id' => $recipient->getId(),
|
||||
'source' => $source,
|
||||
'excerpt' => $excerpt,
|
||||
'revcreation' => $revcreation,
|
||||
],
|
||||
'agent' => $user,
|
||||
] );
|
||||
|
|
|
@ -27,8 +27,13 @@ class EchoCoreThanksPresentationModel extends EchoEventPresentationModel {
|
|||
$msg->params( $this->getViewingUserForGender() );
|
||||
return $msg;
|
||||
} else {
|
||||
// Message is either notification-header-rev-thank or notification-header-log-thank.
|
||||
$msg = $this->getMessageWithAgent( "notification-header-$type-thank" );
|
||||
if ( $this->event->getExtraParam( 'revcreation', null ) ) {
|
||||
// This is a thank on a page creation revision.
|
||||
$msg = $this->getMessageWithAgent( "notification-header-creation-thank" );
|
||||
} else {
|
||||
// Message is either notification-header-rev-thank or notification-header-log-thank.
|
||||
$msg = $this->getMessageWithAgent( "notification-header-$type-thank" );
|
||||
}
|
||||
$msg->params( $this->getTruncatedTitleText( $this->event->getTitle(), true ) );
|
||||
$msg->params( $this->getViewingUserForGender() );
|
||||
return $msg;
|
||||
|
|
Loading…
Reference in a new issue