jenkins-bot has submitted this change and it was merged.

Change subject: Add notifications for summary changes
......................................................................


Add notifications for summary changes

Bug: T125119
Change-Id: I627bd79abeb453491039292cf57d6b51451c659f
---
M autoload.php
M i18n/en.json
M i18n/qqq.json
M includes/Notifications/Controller.php
M includes/Notifications/Notifications.php
A includes/Notifications/SummaryEditedPresentationModel.php
6 files changed, 157 insertions(+), 2 deletions(-)

Approvals:
  Mattflaschen: Looks good to me, approved
  Catrope: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/autoload.php b/autoload.php
index 70a88ee..29188d1 100644
--- a/autoload.php
+++ b/autoload.php
@@ -309,6 +309,7 @@
        'Flow\\Specials\\SpecialEnableFlow' => __DIR__ . 
'/includes/Specials/SpecialEnableFlow.php',
        'Flow\\Specials\\SpecialFlow' => __DIR__ . 
'/includes/Specials/SpecialFlow.php',
        'Flow\\SubmissionHandler' => __DIR__ . 
'/includes/SubmissionHandler.php',
+       'Flow\\SummaryEditedPresentationModel' => __DIR__ . 
'/includes/Notifications/SummaryEditedPresentationModel.php',
        'Flow\\TalkpageManager' => __DIR__ . '/includes/TalkpageManager.php',
        'Flow\\TemplateHelper' => __DIR__ . '/includes/TemplateHelper.php',
        'Flow\\Templating' => __DIR__ . '/includes/Templating.php',
diff --git a/i18n/en.json b/i18n/en.json
index 8316fb2..74f0904 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -290,6 +290,17 @@
        "notification-body-flow-post-edited-user-talk": "$1",
        "notification-header-flow-topic-renamed-v2": "The topic \"'''$1'''\" 
was renamed to \"'''$2'''\".",
        "notification-header-flow-topic-renamed-user-talk": "The topic 
\"'''$1'''\" was renamed to \"'''$2'''\" on '''your talk page'''.",
+       "notification-header-flow-summary-edited": "The summary for 
\"'''$1'''\" was updated.",
+       "notification-header-flow-summary-edited-first": "The topic 
\"'''$1'''\" was summarized.",
+       "notification-bundle-header-flow-summary-edited": "The summary for 
\"'''$1'''\" was updated multiple times.",
+       "notification-body-flow-summary-edited": "$1",
+       "notification-header-flow-summary-edited-user-talk": "The summary for 
\"'''$1'''\" was updated on '''{{GENDER:$2|your}} talk page'''.",
+       "notification-header-flow-summary-edited-first-user-talk": "The topic 
\"'''$1'''\" was summarized on '''{{GENDER:$2|your}} talk page'''.",
+       "notification-bundle-header-flow-summary-edited-user-talk": "The 
summary for \"'''$1'''\" was updated multiple times on '''{{GENDER:$2|your}} 
talk page'''.",
+       "notification-body-flow-summary-edited-user-talk": "$1",
+       "notification-email-subject-flow-summary-edited": "$1 
{{GENDER:$1|updated}} the summary on $2.",
+       "notification-email-batch-body-flow-summary-edited": "$1 
{{GENDER:$1|updated}} the summary on $2.",
+       "notification-email-batch-bundle-body-flow-summary-edited": "$1 and $3 
{{PLURAL:$4|other|others}} {{GENDER:$1|updated}} the summary on $2",
        "notification-header-flow-mention-post": "$1 {{GENDER:$2|mentioned}} 
{{GENDER:$4|you}} in \"'''$5'''\".",
        "notification-header-flow-mention-header": "$1 {{GENDER:$2|mentioned}} 
{{GENDER:$4|you}} in the description of '''$3'''.",
        "notification-header-flow-mention-post-summary": "$1 
{{GENDER:$2|mentioned}} {{GENDER:$4|you}} in \"$5\".",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 1d416a6..b53b9d7 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -300,6 +300,17 @@
        "notification-body-flow-post-edited-user-talk": "Notification body text 
for when a post on a user's talk page is edited. Parameters:\n$1 - snippet of 
the post\n{{notranslate}}",
        "notification-header-flow-topic-renamed-v2": "Notification header text 
for when a topic is renamed. Parameters:\n$1 - old title of the topic\n* $2 - 
new title of the topic\n* $3 - username of the person who receives the 
notification, can be used for GENDER\n{{Related|Notification-header-flow}}",
        "notification-header-flow-topic-renamed-user-talk": "Notification 
header text for when a topic is renamed on a user's talk page . Parameters:\n$1 
- old title of the topic\n* $2 - new title of the topic\n* $3 - username of the 
person who receives the notification, can be used for 
GENDER\n{{Related|Notification-header-flow}}",
+       "notification-header-flow-summary-edited": "Notification header text 
for when a topic summary is edited. Parameters:\n* $1 - title of the topic.\n* 
$2 - name of the user viewing the notification, can be used for 
GENDER.\n{{Related|Notification-header-flow}}",
+       "notification-header-flow-summary-edited-first": "Notification header 
text for when a topic is summarized for the first time. Parameters:\n* $1 - 
title of the topic.\n* $2 - name of the user viewing the notification, can be 
used for GENDER.\n{{Related|Notification-header-flow}}",
+       "notification-bundle-header-flow-summary-edited": "Notification bundle 
header text for when a topic summary is edited multiple times. Parameters:\n* 
$1 - title of the topic.\n* $2 - name of the user viewing the notification, can 
be used for GENDER.\n{{Related|Notification-bundle}}",
+       "notification-body-flow-summary-edited": "Notification body text for 
when a topic summary is edited. Parameters:\n$1 - snippet of the 
post\n{{notranslate}}",
+       "notification-header-flow-summary-edited-user-talk": "Notification 
header text for when a topic summary is edited on a user's talk page. 
Parameters:\n* $1 - title of the topic.\n* $2 - name of the user viewing the 
notification, can be used for GENDER.\n{{Related|Notification-header-flow}}",
+       "notification-header-flow-summary-edited-first-user-talk": 
"Notification header text for when a topic is summarized for the first time on 
a user's talk page. Parameters:\n* $1 - title of the topic.\n* $2 - name of the 
user viewing the notification, can be used for 
GENDER.\n{{Related|Notification-header-flow}}",
+       "notification-bundle-header-flow-summary-edited-user-talk": 
"Notification bundle header text for when a topic summary is edited multiple 
times on a user's talk page. Parameters:\n* $1 - title of the topic.\n* $2 - 
name of the user viewing the notification, can be used for 
GENDER.\n{{Related|Notification-bundle}}",
+       "notification-body-flow-summary-edited-user-talk": "Notification body 
text for when a topic summary is edited on a user's talk page. Parameters:\n$1 
- snippet of the post\n{{notranslate}}",
+       "notification-email-subject-flow-summary-edited": "Subject line of 
notification email for the topic summary being edited. Parameters:\n* $1 - name 
of the user that edited the summary\n* $2 - title of the topic",
+       "notification-email-batch-body-flow-summary-edited": "Email 
notification for the topic summary being edited. Parameters:\n* $1 - name of 
the user that edited the summary\n* $2 - title of the topic",
+       "notification-email-batch-bundle-body-flow-summary-edited": "Email 
notification body when a topic summary is edited multiple times, this message 
is used in both single email and email digest.\n\nParameters:\n* $1 - username 
of the person who edited the summary\n* $2 - title for the topic\n* $3 - the 
count of other action performers, could be number or 
{{msg-mw|Echo-notification-count}}. e.g. 7 others or 99+ others\n* $4 - a 
number used for plural support",
        "notification-header-flow-mention-post": 
"{{doc-singularthey}}\nNotification header text for when a user is mentioned in 
a post or topic title. Parameters:\n* $1 - the formatted username of the person 
who made the post\n* $2 - the username of the user who mentioned the viewing 
user, can be used for GENDER\n* $3 - title of the Flow board\n* $4 - username 
of the person who receives the notification, can be used for GENDER\n* $5 - 
title of the topic\n{{Related|Notification-header-flow}}",
        "notification-header-flow-mention-header": 
"{{doc-singularthey}}\nNotification header text for when a user is mentioned in 
the board description. Parameters:\n* $1 - the formatted username of the person 
who made the post\n* $2 - the username for gender purposes\n* $3 - title of the 
Flow board\n* $4 - username of the person who receives the notification, can be 
used for GENDER\n{{Related|Notification-header-flow}}",
        "notification-header-flow-mention-post-summary": "Notification header 
text for when a user is mentioned in a post summary. Parameters:\n* $1 - the 
formatted username of the person who made the post\n* $2 - the username of the 
user who mentioned the viewing user, can be used for GENDER\n* $4 - username of 
the person who receives the notification, can be used for GENDER\n* $5 - title 
of the topic\n{{Related|Notification-header-flow}}",
diff --git a/includes/Notifications/Controller.php 
b/includes/Notifications/Controller.php
index 27c888d..3b582a5 100644
--- a/includes/Notifications/Controller.php
+++ b/includes/Notifications/Controller.php
@@ -252,9 +252,28 @@
                $user = $revision->getUser();
                $mentionedUsers = $this->getMentionedUsers( $revision );
 
-               // @todo we may also want other topic summary edit 
notifications, some day
+               $extraData['content'] = Utils::htmlToPlaintext( 
$revision->getContent(), 200, $this->language );
+               $extraData['revision-id'] = $revision->getRevisionId();
+               $extraData['prev-revision-id'] = $revision->getPrevRevisionId();
+               $extraData['topic-workflow'] = $topicWorkflow->getId();
+               $extraData['topic-title'] = Utils::htmlToPlaintext( 
$topicRevision->getContent( 'topic-title-html' ), 200, $this->language );
+               $extraData['target-page'] = 
$topicWorkflow->getArticleTitle()->getArticleID();
+               // pass along mentioned users to other notification, so it 
knows who to ignore
+               $extraData['mentioned-users'] = $mentionedUsers;
 
-               $events = array();
+               $info = array(
+                       'type' => $eventName,
+                       'agent' => $user,
+                       'title' => $topicWorkflow->getOwnerTitle(),
+                       'extra' => $extraData,
+               );
+
+               // Allow a specific timestamp to be set - useful when importing 
existing data
+               if ( isset( $data['timestamp'] ) ){
+                       $info['timestamp'] = $data['timestamp'];
+               }
+
+               $events = array( EchoEvent::create( $info ) );
                if ( $mentionedUsers ) {
                        $events[] = $this->generateMentionEvent( $revision, 
$topicRevision, $topicWorkflow, $user, $mentionedUsers );
                }
@@ -515,6 +534,7 @@
 
                        case 'flow-post-reply':
                        case 'flow-post-edited':
+                       case 'flow-summary-edited':
                                $topic = $event->getExtraParam( 
'topic-workflow' );
                                if ( $topic instanceof UUID ) {
                                        $bundleString = $event->getType() . '-' 
. $topic->getAlphadecimal();
diff --git a/includes/Notifications/Notifications.php 
b/includes/Notifications/Notifications.php
index e2f1d40..d04f91c 100644
--- a/includes/Notifications/Notifications.php
+++ b/includes/Notifications/Notifications.php
@@ -119,6 +119,33 @@
                'email-body-batch-params' => array( 'agent', 'old-subject', 
'new-subject', 'title' ),
                'icon' => 'flow-topic-renamed',
        ) + $notificationTemplate,
+       'flow-summary-edited' => array(
+               'presentation-model' => 'Flow\\SummaryEditedPresentationModel',
+               'user-locators' => array(
+                       
'Flow\\NotificationsUserLocator::locateUsersWatchingTopic',
+                       'EchoUserLocator::locateTalkPageOwner'
+               ),
+               'user-filters' => array(
+                       'Flow\\NotificationsUserLocator::locateMentionedUsers',
+               ),
+               'bundle' => array(
+                       'web' => true,
+                       'email' => true,
+               ),
+               'primary-link' => array(
+                       'message' => 'flow-notification-link-text-view-topic',
+                       'destination' => 'flow-post'
+               ),
+               'title-message' => 'notification-header-flow-summary-edited',
+               'title-params' => array( 'subject', 'agent' ),
+               'email-subject-message' => 
'notification-email-subject-flow-summary-edited',
+               'email-subject-params' => array( 'agent', 'subject' ),
+               'email-body-batch-message' => 
'notification-email-batch-body-flow-summary-edited',
+               'email-body-batch-params' => array( 'agent', 'subject' ),
+               'email-body-batch-bundle-message' => 
'notification-email-batch-bundle-body-flow-summary-edited',
+               'email-body-batch-bundle-params' => array( 'agent', 'subject', 
'agent-other-display', 'agent-other-count' ),
+               'icon' => 'flow-topic-renamed',
+       ) + $notificationTemplate,
        'flow-description-edited' => array(
                'presentation-model' => 'Flow\\HeaderEditedPresentationModel',
                'user-locators' => array(
diff --git a/includes/Notifications/SummaryEditedPresentationModel.php 
b/includes/Notifications/SummaryEditedPresentationModel.php
new file mode 100644
index 0000000..1290e74
--- /dev/null
+++ b/includes/Notifications/SummaryEditedPresentationModel.php
@@ -0,0 +1,85 @@
+<?php
+
+namespace Flow;
+
+use Title;
+
+class SummaryEditedPresentationModel extends FlowPresentationModel {
+       public function getIconType() {
+               return 'flow-topic-renamed';
+       }
+
+       public function canRender() {
+               return $this->hasTitle()
+                       && $this->hasValidTopicWorkflowId()
+                       && $this->event->getExtraParam( 'revision-id' ) !== 
null;
+       }
+
+       public function getPrimaryLink() {
+               return $this->getViewTopicLink();
+       }
+
+       public function getSecondaryLinks() {
+               if ( $this->isBundled() ) {
+                       return array( $this->getBoardLink() );
+               } else {
+                       $links = array( $this->getAgentLink() );
+                       if ( $this->isUserTalkPage() && 
$this->event->getExtraParam( 'prev-revision-id' ) !== null ) {
+                               $links[] = $this->getDiffLink();
+                       } else {
+                               $links[] = $this->getBoardLink();
+                       }
+                       return $links;
+               }
+       }
+
+       protected function getHeaderMessageKey() {
+               if ( $this->isBundled() ) {
+                       $key = "notification-bundle-header-{$this->type}";
+               } elseif ( $this->event->getExtraParam( 'prev-revision-id' ) 
=== null ) {
+                       $key = parent::getHeaderMessageKey() . '-first';
+               } else {
+                       $key = parent::getHeaderMessageKey();
+               }
+
+               if ( $this->isUserTalkPage() ) {
+                       $key .= '-user-talk';
+               }
+
+               return $key;
+       }
+
+       public function getHeaderMessage() {
+               $msg = $this->msg( $this->getHeaderMessageKey() );
+               $msg->plaintextParams( $this->getTopicTitle() );
+               $msg->params( $this->getViewingUserForGender() );
+               return $msg;
+       }
+
+       public function getBodyMessage() {
+               $key = "notification-body-{$this->type}";
+               if ( $this->isUserTalkPage() ) {
+                       $key .= '-user-talk';
+               }
+
+               return $this->msg( $key )->params( $this->getContentSnippet() );
+       }
+
+       protected function getDiffLink() {
+               /** @var UrlGenerator $urlGenerator */
+               $urlGenerator = Container::get( 'url_generator' );
+               $anchor = $urlGenerator->diffSummaryLink(
+                       Title::newFromText( $this->event->getExtraParam( 
'topic-workflow' )->getAlphadecimal(), NS_TOPIC ),
+                       $this->event->getExtraParam( 'topic-workflow' ),
+                       $this->event->getExtraParam( 'revision-id' )
+               );
+
+               return array(
+                       'url' => $anchor->getFullURL(),
+                       'label' => $this->msg( 
'notification-link-text-view-changes' )->params( 
$this->getViewingUserForGender() )->text(),
+                       'description' => '',
+                       'icon' => 'changes',
+                       'prioritized' => true,
+               );
+       }
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/273231
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I627bd79abeb453491039292cf57d6b51451c659f
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <mmul...@wikimedia.org>
Gerrit-Reviewer: Catrope <roan.katt...@gmail.com>
Gerrit-Reviewer: Mattflaschen <mflasc...@wikimedia.org>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to