mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-28 01:30:15 +00:00
Bundle mention success and failure notifications
Adds common bundling including messages and icons. Bundling relates to revision now. Changed order how notifications are generated. Now errors will show first, since they are generated last. Bug: T140224 Change-Id: I1069aeb5523db8710da4e8e21065bf447d031e3c
This commit is contained in:
parent
cc35d64a23
commit
272cb9a960
3
Echo.php
3
Echo.php
|
@ -353,6 +353,9 @@ $wgEchoNotificationIcons = array(
|
||||||
'mention-success' => array(
|
'mention-success' => array(
|
||||||
'path' => "$echoIconPath/mention-success.svg",
|
'path' => "$echoIconPath/mention-success.svg",
|
||||||
),
|
),
|
||||||
|
'mention-status-bundle' => array(
|
||||||
|
'path' => "$echoIconPath/mention-status-bundle.svg",
|
||||||
|
),
|
||||||
'reviewed' => array(
|
'reviewed' => array(
|
||||||
'path' => "$echoIconPath/reviewed.svg",
|
'path' => "$echoIconPath/reviewed.svg",
|
||||||
),
|
),
|
||||||
|
|
16
Hooks.php
16
Hooks.php
|
@ -206,21 +206,9 @@ class EchoHooks {
|
||||||
. '-' . $event->getTitle()->getDBkey();
|
. '-' . $event->getTitle()->getDBkey();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'mention-failure':
|
|
||||||
$bundleString = 'mention-failure';
|
|
||||||
if ( $event->getTitle() ) {
|
|
||||||
$bundleString .= '-' . $event->getTitle()->getNamespace()
|
|
||||||
. ':' . $event->getTitle()->getDBkey()
|
|
||||||
. '#' . $event->getExtraParam( 'section-title' );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'mention-success':
|
case 'mention-success':
|
||||||
$bundleString = 'mention-success';
|
case 'mention-failure':
|
||||||
if ( $event->getTitle() ) {
|
$bundleString = 'mention-status-' . $event->getExtraParam( 'revid' );
|
||||||
$bundleString .= '-' . $event->getTitle()->getNamespace()
|
|
||||||
. ':' . $event->getTitle()->getDBkey()
|
|
||||||
. '#' . $event->getExtraParam( 'section-title' );
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -156,6 +156,7 @@
|
||||||
"notification-header-mention-success": "{{GENDER:$2|Your}} mention of $3 was sent.",
|
"notification-header-mention-success": "{{GENDER:$2|Your}} mention of $3 was sent.",
|
||||||
"notification-header-mention-success-bundle": "{{PLURAL:$3|A mention|$3 mentions}} {{GENDER:$2|you made}} on the <strong>$4</strong> talk page {{PLURAL:$3|were}} sent.",
|
"notification-header-mention-success-bundle": "{{PLURAL:$3|A mention|$3 mentions}} {{GENDER:$2|you made}} on the <strong>$4</strong> talk page {{PLURAL:$3|were}} sent.",
|
||||||
"notification-compact-header-mention-success": "<strong>{{GENDER:$2|You mentioned}}:</strong> $3",
|
"notification-compact-header-mention-success": "<strong>{{GENDER:$2|You mentioned}}:</strong> $3",
|
||||||
|
"notification-header-mention-status-bundle": "{{PLURAL:$3|A notification|$3 notifications}} about mentions {{GENDER:$2|you made}} on the <strong>$4</strong> talk page: {{PLURAL:$5|$5 not sent}}, {{PLURAL:$6|$6 sent}}.",
|
||||||
"notification-header-user-rights-add-only": "{{GENDER:$4|Your}} user rights were {{GENDER:$1|changed}}. You have been added to: $2.",
|
"notification-header-user-rights-add-only": "{{GENDER:$4|Your}} user rights were {{GENDER:$1|changed}}. You have been added to: $2.",
|
||||||
"notification-header-user-rights-remove-only": "{{GENDER:$4|Your}} user rights were {{GENDER:$1|changed}}. You are no longer a member of: $2.",
|
"notification-header-user-rights-remove-only": "{{GENDER:$4|Your}} user rights were {{GENDER:$1|changed}}. You are no longer a member of: $2.",
|
||||||
"notification-header-user-rights-add-and-remove": "{{GENDER:$6|Your}} user rights were {{GENDER:$1|changed}}. You have been added to: $2. You are no longer a member of: $4.",
|
"notification-header-user-rights-add-and-remove": "{{GENDER:$6|Your}} user rights were {{GENDER:$1|changed}}. You have been added to: $2. You are no longer a member of: $4.",
|
||||||
|
|
|
@ -149,6 +149,7 @@
|
||||||
"notification-header-mention-success": "Header text for a notification when your mention was successful.\n* $2 - user's name for use in GENDER.\n* $3 - username that was mentioned, can be used for GENDER.",
|
"notification-header-mention-success": "Header text for a notification when your mention was successful.\n* $2 - user's name for use in GENDER.\n* $3 - username that was mentioned, can be used for GENDER.",
|
||||||
"notification-header-mention-success-bundle": "Header text for a bundled notification when multiple mentions succeeded.\n* $2 - user's name for use in GENDER.\n* $3 - number of mentions; uses standard number formatting and used for PLURAL.\n* $4 - talk page title.",
|
"notification-header-mention-success-bundle": "Header text for a bundled notification when multiple mentions succeeded.\n* $2 - user's name for use in GENDER.\n* $3 - number of mentions; uses standard number formatting and used for PLURAL.\n* $4 - talk page title.",
|
||||||
"notification-compact-header-mention-success": "Compact header text for a notification when your mention was successful.\n* $2 - user's name for use in GENDER.\n* $3 - username that was mentioned.",
|
"notification-compact-header-mention-success": "Compact header text for a notification when your mention was successful.\n* $2 - user's name for use in GENDER.\n* $3 - username that was mentioned.",
|
||||||
|
"notification-header-mention-status-bundle": "Header text for a bundled notification when some mentions failed and some succeeded.\n* $2 - user's name for use in GENDER.\n* $3 - number of mentions; uses standard number formatting and used for PLURAL.\n* $4 - talk page title.\n* $5 - number of failed mentions; uses standard number formatting and used for PLURAL.\n* $6 - number of successful mentions; uses standard number formatting and used for PLURAL.",
|
||||||
"notification-header-user-rights-add-only": "Notifications header message when a user is added to 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* $3 - the number of groups that were added, can be used for PLURAL\n* $4 - name of the user viewing the notification, can be used for GENDER",
|
"notification-header-user-rights-add-only": "Notifications header message when a user is added to 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* $3 - the number of groups that were added, can be used for PLURAL\n* $4 - name of the user viewing the notification, can be used for GENDER",
|
||||||
"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-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-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",
|
||||||
|
|
|
@ -174,16 +174,31 @@ abstract class EchoDiscussionParser {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( $userMentions['validMentions'] ) {
|
||||||
|
EchoEvent::create( array(
|
||||||
|
'type' => 'mention',
|
||||||
|
'title' => $title,
|
||||||
|
'extra' => array(
|
||||||
|
'content' => $content,
|
||||||
|
'section-title' => $header,
|
||||||
|
'revid' => $revision->getId(),
|
||||||
|
'mentioned-users' => $userMentions['validMentions'],
|
||||||
|
'notifyAgent' => true
|
||||||
|
),
|
||||||
|
'agent' => $agent,
|
||||||
|
) );
|
||||||
|
}
|
||||||
|
|
||||||
if ( $wgEchoMentionStatusNotifications ) {
|
if ( $wgEchoMentionStatusNotifications ) {
|
||||||
// TODO batch?
|
// TODO batch?
|
||||||
foreach ( $userMentions['unknownUsers'] as $unknownUser ) {
|
foreach ( $userMentions['validMentions'] as $mentionedUserId ) {
|
||||||
EchoEvent::create( array(
|
EchoEvent::create( array(
|
||||||
'type' => 'mention-failure',
|
'type' => 'mention-success',
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'extra' => array(
|
'extra' => array(
|
||||||
'failure-type' => 'user-unknown',
|
'subject-name' => User::newFromId( $mentionedUserId )->getName(),
|
||||||
'subject-name' => $unknownUser,
|
|
||||||
'section-title' => $header,
|
'section-title' => $header,
|
||||||
|
'revid' => $revision->getId(),
|
||||||
'notifyAgent' => true
|
'notifyAgent' => true
|
||||||
),
|
),
|
||||||
'agent' => $agent,
|
'agent' => $agent,
|
||||||
|
@ -199,39 +214,23 @@ abstract class EchoDiscussionParser {
|
||||||
'failure-type' => 'user-anonymous',
|
'failure-type' => 'user-anonymous',
|
||||||
'subject-name' => $anonymousUser,
|
'subject-name' => $anonymousUser,
|
||||||
'section-title' => $header,
|
'section-title' => $header,
|
||||||
|
'revid' => $revision->getId(),
|
||||||
'notifyAgent' => true
|
'notifyAgent' => true
|
||||||
),
|
),
|
||||||
'agent' => $agent,
|
'agent' => $agent,
|
||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( !$userMentions['validMentions'] ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
EchoEvent::create( array(
|
|
||||||
'type' => 'mention',
|
|
||||||
'title' => $title,
|
|
||||||
'extra' => array(
|
|
||||||
'content' => $content,
|
|
||||||
'section-title' => $header,
|
|
||||||
'revid' => $revision->getId(),
|
|
||||||
'mentioned-users' => $userMentions['validMentions'],
|
|
||||||
),
|
|
||||||
'agent' => $agent,
|
|
||||||
) );
|
|
||||||
|
|
||||||
if ( $wgEchoMentionStatusNotifications ) {
|
|
||||||
// TODO batch?
|
// TODO batch?
|
||||||
foreach ( $userMentions['validMentions'] as $mentionedUserId ) {
|
foreach ( $userMentions['unknownUsers'] as $unknownUser ) {
|
||||||
EchoEvent::create( array(
|
EchoEvent::create( array(
|
||||||
'type' => 'mention-success',
|
'type' => 'mention-failure',
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'extra' => array(
|
'extra' => array(
|
||||||
'subject-name' => User::newFromId( $mentionedUserId )->getName(),
|
'failure-type' => 'user-unknown',
|
||||||
|
'subject-name' => $unknownUser,
|
||||||
'section-title' => $header,
|
'section-title' => $header,
|
||||||
'notifyAgent' => true
|
'revid' => $revision->getId(),
|
||||||
),
|
),
|
||||||
'agent' => $agent,
|
'agent' => $agent,
|
||||||
) );
|
) );
|
||||||
|
|
|
@ -11,6 +11,9 @@ class EchoMentionStatusPresentationModel extends EchoEventPresentationModel {
|
||||||
use EchoPresentationModelSectionTrait;
|
use EchoPresentationModelSectionTrait;
|
||||||
|
|
||||||
public function getIconType() {
|
public function getIconType() {
|
||||||
|
if ( $this->isMixedBundle() ) {
|
||||||
|
return 'mention-status-bundle';
|
||||||
|
}
|
||||||
if ( $this->isMentionSuccess() ) {
|
if ( $this->isMentionSuccess() ) {
|
||||||
return 'mention-success';
|
return 'mention-success';
|
||||||
}
|
}
|
||||||
|
@ -25,6 +28,16 @@ class EchoMentionStatusPresentationModel extends EchoEventPresentationModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $this->isBundled() ) {
|
if ( $this->isBundled() ) {
|
||||||
|
if ( $this->isMixedBundle() ) {
|
||||||
|
$successCount = $this->getBundleSuccessCount();
|
||||||
|
|
||||||
|
$msg = $this->getMessageWithAgent( 'notification-header-mention-status-bundle' );
|
||||||
|
$msg->numParams( $this->getBundleCount() );
|
||||||
|
$msg->params( $this->getTruncatedTitleText( $this->event->getTitle() ) );
|
||||||
|
$msg->numParams( $this->getBundleCount() - $successCount );
|
||||||
|
$msg->numParams( $successCount );
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
if ( $this->isMentionSuccess() ) {
|
if ( $this->isMentionSuccess() ) {
|
||||||
$msgKey = 'notification-header-mention-success-bundle';
|
$msgKey = 'notification-header-mention-success-bundle';
|
||||||
} else {
|
} else {
|
||||||
|
@ -86,6 +99,14 @@ class EchoMentionStatusPresentationModel extends EchoEventPresentationModel {
|
||||||
return array( $talkPageLink );
|
return array( $talkPageLink );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isMentionSuccessEvent( EchoEvent $event ) {
|
||||||
|
return $event->getType() === 'mention-success';
|
||||||
|
}
|
||||||
|
|
||||||
|
private function isMentionSuccess() {
|
||||||
|
return $this->isMentionSuccessEvent( $this->event );
|
||||||
|
}
|
||||||
|
|
||||||
private function getSubjectName() {
|
private function getSubjectName() {
|
||||||
return $this->event->getExtraParam( 'subject-name', '' );
|
return $this->event->getExtraParam( 'subject-name', '' );
|
||||||
}
|
}
|
||||||
|
@ -98,12 +119,18 @@ class EchoMentionStatusPresentationModel extends EchoEventPresentationModel {
|
||||||
return $this->getType() === 'mention-failure-too-many';
|
return $this->getType() === 'mention-failure-too-many';
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isMentionSuccess() {
|
|
||||||
return $this->getType() === 'mention-success';
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getMaxMentions() {
|
private function getMaxMentions() {
|
||||||
global $wgEchoMaxMentionsCount;
|
global $wgEchoMaxMentionsCount;
|
||||||
return $this->event->getExtraParam( 'max-mentions', $wgEchoMaxMentionsCount );
|
return $this->event->getExtraParam( 'max-mentions', $wgEchoMaxMentionsCount );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getBundleSuccessCount() {
|
||||||
|
return $this->getBundleCount( false, array( $this, 'isMentionSuccessEvent' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
private function isMixedBundle() {
|
||||||
|
$successCount = $this->getBundleSuccessCount();
|
||||||
|
$failCount = $this->getBundleCount() - $successCount;
|
||||||
|
return $successCount > 0 && $failCount > 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
4
modules/icons/mention-status-bundle.svg
Normal file
4
modules/icons/mention-status-bundle.svg
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 241.12238 168.78567">
|
||||||
|
<path d="M36.168 168.786h204.954l-36.168-36.169V0H0v132.617c0 20.496 15.673 36.169 36.168 36.169z" fill="#165ca0"/><path d="M109.656 102.624H96.183l-2.185-68.481h17.842l-2.184 68.48zm-15.84 26.864v-13.601h17.66v13.601h-17.66z" style="-inkscape-font-specification:'Liberation Sans'" font-family="Liberation Sans" letter-spacing="0" fill="#fff" color="#000" font-weight="400" font-size="40" word-spacing="0" overflow="visible"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 574 B |
Loading…
Reference in a new issue