mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 07:54:13 +00:00
Merge "Display revert edit summary in revert notification body"
This commit is contained in:
commit
18bffba313
|
@ -462,6 +462,7 @@ class EchoHooks {
|
|||
'reverted-user-id' => $victimId,
|
||||
'reverted-revision-id' => $undidRevId,
|
||||
'method' => 'undo',
|
||||
'summary' => $summary,
|
||||
),
|
||||
'agent' => $user,
|
||||
) );
|
||||
|
|
|
@ -92,7 +92,8 @@
|
|||
"notification-welcome-link": "",
|
||||
"notification-welcome-linktext": "Welcome",
|
||||
"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 has|edits on $3 have}} been {{GENDER:$2|reverted}} by $1.",
|
||||
"notification-header-reverted": "Your {{PLURAL:$4|edit on $3 was|edits on $3 were}} {{GENDER:$2|reverted}}",
|
||||
"notification-body-reverted": "$1",
|
||||
"notification-emailuser": "[[User:$1|$1]] {{GENDER:$1|sent}} you an email.",
|
||||
"notification-header-emailuser": "$1 {{GENDER:$2|sent}} you an email.",
|
||||
"notification-edit-talk-page-email-subject2": "$1 {{GENDER:$1|left}} you a message on {{SITENAME}}",
|
||||
|
|
|
@ -113,7 +113,8 @@
|
|||
"notification-welcome-link": "{{notranslate}}",
|
||||
"notification-welcome-linktext": "Link text for link to the wiki's welcome or introduction page.\n{{Identical|Welcome}}",
|
||||
"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": "Flyout-specific format for displaying notifications 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-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}}",
|
||||
"notification-emailuser": "Format for displaying notifications of a user has sent an email to another user. Parameters:\n* $1 - the username of the person the email, plain text. Can be used for GENDER.",
|
||||
"notification-header-emailuser": "Flyout-specific format for displaying notifications of user has sent an email to another user.\n\nParameters:\n* $1 - the formatted username of the person who sent the email.\n* $2 - the username for GENDER.",
|
||||
"notification-edit-talk-page-email-subject2": "Email subject. Parameters:\n* $1 - a username which can be used for gender support",
|
||||
|
|
|
@ -134,7 +134,8 @@ class EchoEditUserTalkPresentationModel extends EchoEventPresentationModel {
|
|||
}
|
||||
|
||||
private function getRevBeforeFirstNotification() {
|
||||
$firstNotificationRevId = end( $this->getBundledEvents() )->getExtraParam( 'revid' );
|
||||
$events = $this->getBundledEvents();
|
||||
$firstNotificationRevId = end( $events )->getExtraParam( 'revid' );
|
||||
return $this->event->getTitle()->getPreviousRevisionID( $firstNotificationRevId );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,26 @@ class EchoRevertedPresentationModel extends EchoEventPresentationModel {
|
|||
return $msg;
|
||||
}
|
||||
|
||||
public function getBodyMessage() {
|
||||
$summary = $this->event->getExtraParam( 'summary' );
|
||||
if ( !$this->isAutomaticSummary( $summary ) && $this->userCan( Revision::DELETED_COMMENT ) ) {
|
||||
$msg = $this->msg( "notification-body-{$this->type}" );
|
||||
$msg->params( $this->formatSummary( $summary ) );
|
||||
return $msg;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function formatSummary( $wikitext ) {
|
||||
$html = Linker::formatLinksInComment( Sanitizer::escapeHtmlAllowEntities( $wikitext ) );
|
||||
return EchoDiscussionParser::getTextSnippet(
|
||||
$html,
|
||||
$this->language,
|
||||
30
|
||||
);
|
||||
}
|
||||
|
||||
public function getPrimaryLink() {
|
||||
$url = $this->event->getTitle()->getLocalURL( array(
|
||||
'oldid' => 'prev',
|
||||
|
@ -29,7 +49,7 @@ class EchoRevertedPresentationModel extends EchoEventPresentationModel {
|
|||
}
|
||||
|
||||
public function getSecondaryLinks() {
|
||||
return array( $this->getAgentLink() );
|
||||
return array( $this->getAgentLink(), $this->getTitleLink() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,4 +65,24 @@ class EchoRevertedPresentationModel extends EchoEventPresentationModel {
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
private function getTitleLink() {
|
||||
$talkpage = $this->event->getTitle()->getTalkPage();
|
||||
return array(
|
||||
'label' => $talkpage->getPrefixedText(),
|
||||
'url' => $talkpage->getFullURL(),
|
||||
'icon' => 'speechBubbles',
|
||||
'prioritized' => true,
|
||||
'description' => null,
|
||||
);
|
||||
}
|
||||
|
||||
private function isAutomaticSummary( $summary ) {
|
||||
$autoSummaryMsg = wfMessage( 'undo-summary' )->inContentLanguage();
|
||||
$autoSummaryMsg->params( $this->event->getExtraParam( 'reverted-revision-id' ) );
|
||||
$autoSummaryMsg->params( $this->getViewingUserForGender() );
|
||||
$autoSummary = $autoSummaryMsg->text();
|
||||
|
||||
return $summary === $autoSummary;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue