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

Change subject: Topic creator should be notified on post reply/edit/moderation
......................................................................


Topic creator should be notified on post reply/edit/moderation

depends on Echo patch: https://gerrit.wikimedia.org/r/#/c/87277/

Change-Id: Ife2e63855a334d031b3b94191fd22b0c7bd9c4c9
---
M Flow.i18n.php
M includes/Notifications/Controller.php
M includes/Notifications/Formatter.php
M includes/Notifications/Notifications.php
4 files changed, 79 insertions(+), 42 deletions(-)

Approvals:
  Matthias Mullie: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Flow.i18n.php b/Flow.i18n.php
index 24fb4b8..95a8854 100644
--- a/Flow.i18n.php
+++ b/Flow.i18n.php
@@ -84,7 +84,8 @@
        // Notification message
        'flow-notification-reply' => '$1 {{GENDER:$1|replied}} to your [$5 
post] in $2 on "$4".',
        'flow-notification-reply-bundle' => '$1 and $5 
{{PLURAL:$6|other|others}} {{GENDER:$1|replied}} to your [$4 post] in $2 on 
"$3".',
-       'flow-notification-edit' => '$1 {{GENDER:$1|edited}} your [$5 post] in 
$2 on [[$3|$4]].',
+       'flow-notification-edit' => '$1 {{GENDER:$1|edited}} a [$5 post] in $2 
on [[$3|$4]].',
+       'flow-notification-edit-bundle' => '$1 and $5 
{{PLURAL:$6|other|others}} {{GENDER:$1|edited}} a [$4 post] in $2 on "$3".',
        'flow-notification-newtopic' => '$1 {{GENDER:$1|created}} a [$5 new 
topic] on [[$2|$3]]: $4.',
        'flow-notification-rename' => '$1 {{GENDER:$1|changed}} the title of 
[$2 $3] to "$4" on [[$5|$6]].',
        'flow-notification-mention' => '$1 {{GENDER:$1|mentioned}} you in their 
[$2 post] in "$3" on "$4"',
@@ -102,6 +103,7 @@
        'flow-notification-mention-email-batch-body' => '$1 
{{GENDER:$1|mentioned}} you in their post in "$2" on "$3"',
        'flow-notification-edit-email-subject' => '$1 {{GENDER:$1|edited}} your 
post',
        'flow-notification-edit-email-batch-body' => '$1 {{GENDER:$1|edited}} 
your post in $2 on "$3"',
+       'flow-notification-edit-email-batch-bundle-body' => '$1 and $4 
{{PLURAL:$5|other|others}} {{GENDER:$1|edited}} a post in $2 on "$3"',
        'flow-notification-rename-email-subject' => '$1 {{GENDER:$1|renamed}} 
your topic',
        'flow-notification-rename-email-batch-body' => '$1 
{{GENDER:$1|renamed}} your topic $2 to $3 on "$4"',
        'flow-notification-newtopic-email-subject' => '$1 {{GENDER:$1|created}} 
a new topic on $2',
@@ -274,6 +276,16 @@
 * $1 Name of the user that edited the post
 * $2 Name of the topic the edited post belongs to
 * $3 Title of the page the topic belongs to',
+       'flow-notification-edit-email-batch-bundle-body' => 'Email notification 
body when a user receives post edits from multiple users, this message is used 
in both single email and email digest.
+
+Parameters:
+* $1 - username of the person who replied
+* $2 - title of the topic
+* $3 - title for the page that the Flow board is attached to
+* $4 - the count of other action performers, could be number or 
{{msg-mw|Echo-notification-count}}. e.g. 7 others or 99+ others
+* $5 - a number used for plural support
+See also:
+* {{msg-mw|Flow-notification-edit-bundle}}',
        'flow-notification-rename-email-subject' => 'Subject line of 
notification E-mail for topic being renamed
 * $1 - Name of the user that renamed the topic',
        'flow-notification-rename-email-batch-body' => 'E-mail notification for 
topic being renamed
@@ -295,7 +307,7 @@
 * $4 - Title for the page that the Flow board is attached to
 * $5 - Permanent URL for the post
 {{Related|Flow-notification}}',
-       'flow-notification-reply-bundle' => 'Notification text for when a user 
receives replies from multiple users on the same post/topic.
+       'flow-notification-reply-bundle' => 'Notification text for when a user 
receives replies from multiple users on the same topic.
 
 Parameters:
 * $1 - username of the person who replied
@@ -313,6 +325,17 @@
 * $4 - Title for the page that the Flow board is attached to
 * $5 - Permanent URL for the post
 {{Related|Flow-notification}}",
+       'flow-notification-edit-bundle' => 'Notification text for when a user 
receives post edits from multiple users on the same topic.
+
+Parameters:
+* $1 - username of the person who edited post
+* $2 - title of the topic
+* $3 - title for the page that the Flow board is attached to
+* $4 - permantent URL for the topic
+* $5 - the count of other action performers, could be number or 
{{msg-mw|Echo-notification-count}}. e.g. 7 others or 99+ others
+* $6 - a number used for plural support
+See also:
+* {{msg-mw|Flow-notification-edit-email-batch-bundle-body}}',
        'flow-notification-newtopic' => 'Notification text for when a new topic 
is created. Parameters:
 * $1 - Username of the person who created the topic
 * $2 - Title for the Flow board
diff --git a/includes/Notifications/Controller.php 
b/includes/Notifications/Controller.php
index f5dee8e..d3fc96b 100644
--- a/includes/Notifications/Controller.php
+++ b/includes/Notifications/Controller.php
@@ -306,18 +306,11 @@
        public static function onEchoGetBundleRules( $event, &$bundleString ) {
                switch ( $event->getType() ) {
                        case 'flow-post-reply':
+                       case 'flow-post-edited':
                                $extra = $event->getExtra();
-
-                               if ( isset( $extra['reply-to'] ) ) {
-                                       $postId = $extra['reply-to'];
-                               } elseif ( isset( $extra['post-id'] ) ) {
-                                       $postId = $extra['post-id'];
-                               } else {
-                                       $postId = null;
-                               }
-
-                               if ( $postId ) {
-                                       $bundleString = 'flow-post-reply-' . 
$postId->getHex();
+                               $topic = $extra['topic-workflow'];
+                               if ( $topic ) {
+                                       $bundleString = $event->getType() . '-' 
. $topic->getHex();
                                }
                        break;
                }
@@ -351,17 +344,42 @@
                        }
                        break;
                case 'flow-topic-renamed':
-                       $postId = $extra['topic-workflow'];
+                       $users += self::getCreatorsFromPostIDs( array( 
$extra['topic-workflow'] ) );
+                       break;
                case 'flow-post-reply':
                case 'flow-post-edited':
                case 'flow-post-moderated':
                        if ( isset( $extra['reply-to'] ) ) {
                                $postId = $extra['reply-to'];
-                       } elseif ( !isset( $postId ) || !$postId ) {
+                       } else {
                                $postId = $extra['post-id'];
                        }
 
-                       $post = $storage->find(
+                       $ids = array( $postId );
+                       $topic = $extra['topic-workflow'];
+
+                       if ( $topic && $topic->getBinary() != 
$postId->getBinary() ) {
+                               $ids[] = $topic;
+                       }
+                       $users += self::getCreatorsFromPostIDs( $ids );
+                       break;
+               default:
+                       // Do nothing
+               }
+               return true;
+       }
+
+       /**
+        * Retrieves the post creators from a set of posts.
+        * @param  array  $posts Array of UUIDs or hex representations
+        * @return array Associative array, of user ID => User object.
+        */
+       protected static function getCreatorsFromPostIDs( array $posts ) {
+               $users = array();
+               $container = Container::getContainer();
+               
+               foreach ( $posts as $postId ) {
+                       $post = $container['storage']->find(
                                'PostRevision',
                                array(
                                        'tree_rev_descendant_id' => 
UUID::create( $postId )
@@ -382,10 +400,8 @@
                                        $users[$user->getId()] = $user;
                                }
                        }
-                       break;
-               default:
-                       // Do nothing
                }
-               return true;
-       }
+
+               return $users;
+    }
 }
\ No newline at end of file
diff --git a/includes/Notifications/Formatter.php 
b/includes/Notifications/Formatter.php
index 2199415..25d7ebe 100644
--- a/includes/Notifications/Formatter.php
+++ b/includes/Notifications/Formatter.php
@@ -42,24 +42,21 @@
                        }
                } elseif ( $param === 'post-permalink' ) {
                        $postId = $extra['post-id'];
-                       $url = $this->getUrlGenerator()->buildUrl(
-                               $event->getTitle(),
+                       $urlParams = array( );
+
+                       if ( $this->bundleData['raw-data-count'] <= 1 ) {
+                               $urlParams['topic[postId]'] = $postId->getHex();
+                       }
+
+                       $url = $this->getUrlGenerator()->generateUrl(
+                               $extra['topic-workflow'],
                                'view',
-                               array(
-                                       'topic[postId]' => $postId->getHex(),
-                                       'workflow' => 
$extra['topic-workflow']->getHex(),
-                               )
+                               $urlParams
                        );
 
                        $message->params( $url );
                } elseif ( $param === 'topic-permalink' ) {
-                       $url = $this->getUrlGenerator()->buildUrl(
-                               $event->getTitle(),
-                               'view',
-                               array(
-                                       'workflow' => 
$extra['topic-workflow']->getHex(),
-                               )
-                       );
+                       $url = $this->getUrlGenerator()->generateUrl( 
$extra['topic-workflow'] );
 
                        $message->params( $url );
                } elseif ( $param == 'flow-title' ) {
@@ -98,10 +95,11 @@
                                $post  = $event->getExtraParam( 'post-id' );
                                $flow  = $event->getExtraParam( 
'topic-workflow' );
                                if ( $post && $flow && $title ) {
-                                       list( $target, $query ) =
-                                               $urlGenerator->generateUrlData( 
$flow, array(
-                                                       'topic[postId]' => 
$post->getHex(),
-                                               ) );
+                                       $urlParams = array( 'workflow' => 
$flow->getHex() );
+                                       if ( 
$this->bundleData['raw-data-count'] <= 1 ) {
+                                               $urlParams['topic[postId]'] = 
$post->getHex();  
+                                       }
+                                       list( $target, $query ) = 
$urlGenerator->generateUrlData( $flow, $urlParams );
                                }
                                break;
                        case 'flow-board':
diff --git a/includes/Notifications/Notifications.php 
b/includes/Notifications/Notifications.php
index 24cf052..efaf34c 100644
--- a/includes/Notifications/Notifications.php
+++ b/includes/Notifications/Notifications.php
@@ -19,10 +19,6 @@
                ),
                'title-message' => 'flow-notification-newtopic',
                'title-params' => array( 'agent', 'flow-title', 'title', 
'subject', 'topic-permalink' ),
-               'bundle' => array(
-                       'web' => true,
-                       'email' => false
-               ),
                'email-subject-message' => 
'flow-notification-newtopic-email-subject',
                'email-subject-params' => array(),
                'email-body-batch-message' => 
'flow-notification-newtopic-email-batch-body',
@@ -69,10 +65,14 @@
                        'web' => true,
                        'email' => false
                ),
+               'bundle-message' => 'flow-notification-edit-bundle',
+               'bundle-params' => array( 'agent', 'subject', 'title', 
'post-permalink', 'agent-other-display', 'agent-other-count' ),
                'email-subject-message' => 
'flow-notification-edit-email-subject',
                'email-subject-params' => array( 'agent' ),
                'email-body-batch-message' => 
'flow-notification-edit-email-batch-body',
                'email-body-batch-params' => array( 'agent', 'subject', 'title' 
),
+               'email-body-batch-bundle-message' => 
'flow-notification-edit-email-batch-bundle-body',
+               'email-body-batch-bundle-params' => array( 'agent', 'subject', 
'title', 'agent-other-display', 'agent-other-count' ),
        ) + $notificationTemplate,
        'flow-topic-renamed' => array(
                'primary-link' => array(

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ife2e63855a334d031b3b94191fd22b0c7bd9c4c9
Gerrit-PatchSet: 9
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Bsitu <bs...@wikimedia.org>
Gerrit-Reviewer: Bsitu <bs...@wikimedia.org>
Gerrit-Reviewer: EBernhardson (WMF) <ebernhard...@wikimedia.org>
Gerrit-Reviewer: Matthias Mullie <mmul...@wikimedia.org>
Gerrit-Reviewer: Siebrand <siebr...@wikimedia.org>
Gerrit-Reviewer: Werdna <agarr...@wikimedia.org>
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