<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][10895] trunk: Activity: Fine-tune activity reply screen notifications when activity stream commenting is enabled.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://buddypress.trac.wordpress.org/changeset/10895">10895</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://buddypress.trac.wordpress.org/changeset/10895","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>r-a-y</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-06-22 21:17:23 +0000 (Wed, 22 Jun 2016)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Activity: Fine-tune activity reply screen notifications when activity stream commenting is enabled.

Previously, if "activity stream commenting on blog and forum posts" is
enabled and a reply was created from the Activity Directory page for a
blog post activity item, clicking on the activity reply notification
would not mark the notification as read.

Also, if a member decides to post a comment from the blog post permalink,
a screen notification would not be added.

This commit fixes these issues and adds a unit test.

Props r-a-y, dcavins, imath.

Fixes <a href="http://buddypress.trac.wordpress.org/ticket/7135">#7135</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcbpactivitybpactivitynotificationsphp">trunk/src/bp-activity/bp-activity-notifications.php</a></li>
<li><a href="#trunksrcbpblogsbpblogsfunctionsphp">trunk/src/bp-blogs/bp-blogs-functions.php</a></li>
<li><a href="#trunktestsphpunittestcasesactivitynotificationsphp">trunk/tests/phpunit/testcases/activity/notifications.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcbpactivitybpactivitynotificationsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-activity/bp-activity-notifications.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-activity/bp-activity-notifications.php       2016-06-22 21:10:09 UTC (rev 10894)
+++ trunk/src/bp-activity/bp-activity-notifications.php 2016-06-22 21:17:23 UTC (rev 10895)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -208,9 +208,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @param int    $secondary_item_id In the case of at-mentions, this is the mentioner's ID.
</span><span class="cx" style="display: block; padding: 0 10px">  * @param int    $total_items       The total number of notifications to format.
</span><span class="cx" style="display: block; padding: 0 10px">  * @param string $format            'string' to get a BuddyBar-compatible notification, 'array' otherwise.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int    $id                Optional. The notification ID.
</ins><span class="cx" style="display: block; padding: 0 10px">  * @return string $return Formatted @mention notification.
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function bp_activity_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function bp_activity_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string', $id = 0 ) {
</ins><span class="cx" style="display: block; padding: 0 10px">         $action_filter = $action;
</span><span class="cx" style="display: block; padding: 0 10px">        $return        = false;
</span><span class="cx" style="display: block; padding: 0 10px">        $activity_id   = $item_id;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -225,10 +226,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        $amount        = 'single';
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( (int) $total_items > 1 ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                $text = sprintf( __( 'You have %1$d new mentions', 'buddypress' ), (int) $total_items );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         $text   = sprintf( __( 'You have %1$d new mentions', 'buddypress' ), (int) $total_items );
</ins><span class="cx" style="display: block; padding: 0 10px">                                 $amount = 'multiple';
</span><span class="cx" style="display: block; padding: 0 10px">                        } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                $text =  sprintf( __( '%1$s mentioned you', 'buddypress' ), $user_fullname );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         $text = sprintf( __( '%1$s mentioned you', 'buddypress' ), $user_fullname );
</ins><span class="cx" style="display: block; padding: 0 10px">                         }
</span><span class="cx" style="display: block; padding: 0 10px">                break;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -242,8 +243,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                $text   = sprintf( __( 'You have %1$d new replies', 'buddypress' ), (int) $total_items );
</span><span class="cx" style="display: block; padding: 0 10px">                                $amount = 'multiple';
</span><span class="cx" style="display: block; padding: 0 10px">                        } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                $link   = bp_activity_get_permalink( $activity_id );
-                               $text   =  sprintf( __( '%1$s commented on one of your updates', 'buddypress' ), $user_fullname );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         $link = add_query_arg( 'nid', (int) $id, bp_activity_get_permalink( $activity_id ) );
+                               $text = sprintf( __( '%1$s commented on one of your updates', 'buddypress' ), $user_fullname );
</ins><span class="cx" style="display: block; padding: 0 10px">                         }
</span><span class="cx" style="display: block; padding: 0 10px">                break;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -257,8 +258,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                $text   = sprintf( __( 'You have %1$d new comment replies', 'buddypress' ), (int) $total_items );
</span><span class="cx" style="display: block; padding: 0 10px">                                $amount = 'multiple';
</span><span class="cx" style="display: block; padding: 0 10px">                        } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                $link   = bp_activity_get_permalink( $activity_id );
-                               $text   =  sprintf( __( '%1$s replied to one your activity comments', 'buddypress' ), $user_fullname );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         $link = add_query_arg( 'nid', (int) $id, bp_activity_get_permalink( $activity_id ) );
+                               $text = sprintf( __( '%1$s replied to one your activity comments', 'buddypress' ), $user_fullname );
</ins><span class="cx" style="display: block; padding: 0 10px">                         }
</span><span class="cx" style="display: block; padding: 0 10px">                break;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -365,7 +366,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        if ( bp_is_active( 'notifications' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                bp_notifications_add_notification( array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'user_id'           => $activity->user_id,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'item_id'           => $activity->id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 'item_id'           => $comment_id,
</ins><span class="cx" style="display: block; padding: 0 10px">                         'secondary_item_id' => $commenter_id,
</span><span class="cx" style="display: block; padding: 0 10px">                        'component_name'    => buddypress()->activity->id,
</span><span class="cx" style="display: block; padding: 0 10px">                        'component_action'  => 'update_reply',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -389,7 +390,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        if ( bp_is_active( 'notifications' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                bp_notifications_add_notification( array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'user_id'           => $activity_comment->user_id,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'item_id'           => $activity_comment->item_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 'item_id'           => $comment_id,
</ins><span class="cx" style="display: block; padding: 0 10px">                         'secondary_item_id' => $commenter_id,
</span><span class="cx" style="display: block; padding: 0 10px">                        'component_name'    => buddypress()->activity->id,
</span><span class="cx" style="display: block; padding: 0 10px">                        'component_action'  => 'comment_reply',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -426,7 +427,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * Mark at-mention notification as read when user visits the activity with the mention.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 2.0.0
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 2.6.0 Mark notifications for 'update_reply' and 'comment_reply' actions
</del><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @param BP_Activity_Activity $activity Activity object.
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -439,29 +439,36 @@
</span><span class="cx" style="display: block; padding: 0 10px">                return;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        /**
-        * Filter here to add the notification actions to mark as read
-        * when the single activity is displayed.
-        *
-        * @since 2.6.0
-        *
-        * @param array $value List of notification actions to mark as read.
-        */
-       $notification_actions = apply_filters( 'bp_activity_notification_actions_single_activity', array(
-               'new_at_mention',
-               'update_reply',
-               'comment_reply',
-       ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Mark as read any notifications for the current user related to this activity item.
+       bp_notifications_mark_notifications_by_item_id( bp_loggedin_user_id(), $activity->id, buddypress()->activity->id, 'new_at_mention' );
+}
+add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_screen_notifications_single_activity_permalink' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $user_id   = bp_loggedin_user_id();
-       $component = buddypress()->activity->id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Mark non-mention notifications as read when user visits our read permalink.
+ *
+ * In particular, 'update_reply' and 'comment_reply' notifications are handled
+ * here. See {@link bp_activity_format_notifications()} for more info.
+ *
+ * @since 2.6.0
+ */
+function bp_activity_remove_screen_notifications_for_non_mentions() {
+       if ( false === bp_is_active( 'notifications' ) || false === is_singular() || false === is_user_logged_in() || empty( $_GET['nid'] ) ) {
+               return;
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        foreach ( $notification_actions as $action ) {
-               // Mark as read any notifications for the current user related to this activity item.
-               bp_notifications_mark_notifications_by_item_id( $user_id, $activity->id, $component, $action );
-       }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Mark notification as read.
+       BP_Notifications_Notification::update(
+               array(
+                       'is_new'  => false
+               ),
+               array(
+                       'user_id' => bp_loggedin_user_id(),
+                       'id'      => (int) $_GET['nid']
+               )
+       );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_screen_notifications_single_activity_permalink' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+add_action( 'bp_screens', 'bp_activity_remove_screen_notifications_for_non_mentions' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px">  * Delete at-mention notifications when the corresponding activity item is deleted.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -480,3 +487,57 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'bp_activity_deleted_activities', 'bp_activity_at_mention_delete_notification', 10 );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+/**
+ * Add a notification for post comments to the post author or post commenter.
+ *
+ * Requires "activity stream commenting on blog and forum posts" to be enabled.
+ *
+ * @since 2.6.0
+ *
+ * @param int        $activity_id          The activity comment ID.
+ * @param WP_Comment $post_type_comment    WP Comment object.
+ * @param array      $activity_args        Activity comment arguments.
+ * @param object     $activity_post_object The post type tracking args object.
+ */
+function bp_activity_add_notification_for_synced_blog_comment( $activity_id, $post_type_comment, $activity_args, $activity_post_object ) {
+       // If activity comments are disabled for WP posts, stop now!
+       if ( bp_disable_blogforum_comments() || empty( $activity_id ) || false === bp_is_active( 'notifications' ) ) {
+               return;
+       }
+
+       // Send a notification to the blog post author.
+       if ( (int) $post_type_comment->post->post_author !== (int) $activity_args['user_id'] ) {
+               // Only add a notification if comment author is a registered user.
+               // @todo Should we remove this restriction?
+               if ( ! empty( $post_type_comment->user_id ) ) {
+                       bp_notifications_add_notification( array(
+                               'user_id'           => $post_type_comment->post->post_author,
+                               'item_id'           => $activity_id,
+                               'secondary_item_id' => $post_type_comment->user_id,
+                               'component_name'    => buddypress()->activity->id,
+                               'component_action'  => 'update_reply',
+                               'date_notified'     => $post_type_comment->comment_date_gmt,
+                               'is_new'            => 1,
+                       ) );
+               }
+       }
+
+       // Send a notification to the parent comment author for follow-up comments.
+       if ( ! empty( $post_type_comment->comment_parent ) ) {
+               $parent_comment = get_comment( $post_type_comment->comment_parent );
+
+               if ( ! empty( $parent_comment->user_id ) && (int) $parent_comment->user_id !== (int) $activity_args['user_id'] ) {
+                       bp_notifications_add_notification( array(
+                               'user_id'           => $parent_comment->user_id,
+                               'item_id'           => $activity_id,
+                               'secondary_item_id' => $post_type_comment->user_id,
+                               'component_name'    => buddypress()->activity->id,
+                               'component_action'  => 'comment_reply',
+                               'date_notified'     => $post_type_comment->comment_date_gmt,
+                               'is_new'            => 1,
+                       ) );
+               }
+       }
+}
+add_action( 'bp_blogs_comment_sync_activity_comment', 'bp_activity_add_notification_for_synced_blog_comment', 10, 4 );
</ins></span></pre></div>
<a id="trunksrcbpblogsbpblogsfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-blogs/bp-blogs-functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-blogs/bp-blogs-functions.php 2016-06-22 21:10:09 UTC (rev 10894)
+++ trunk/src/bp-blogs/bp-blogs-functions.php   2016-06-22 21:17:23 UTC (rev 10895)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -715,6 +715,18 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                        bp_activity_update_meta( $activity_id, 'post_url', esc_url_raw( add_query_arg( 'p', $comment->post->ID, home_url( '/' ) ) ) );
</span><span class="cx" style="display: block; padding: 0 10px">                                }
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+                       /**
+                        * Fires after an activity comment is added from a WP post comment.
+                        *
+                        * @since 2.6.0
+                        *
+                        * @param int        $activity_id          The activity comment ID.
+                        * @param WP_Comment $post_type_comment    WP Comment object.
+                        * @param array      $activity_args        Activity comment arguments.
+                        * @param object     $activity_post_object The post type tracking args object.
+                        */
+                       do_action( 'bp_blogs_comment_sync_activity_comment', $activity_id, $comment, $activity_args, $activity_post_object );
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre></div>
<a id="trunktestsphpunittestcasesactivitynotificationsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/testcases/activity/notifications.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/testcases/activity/notifications.php  2016-06-22 21:10:09 UTC (rev 10894)
+++ trunk/tests/phpunit/testcases/activity/notifications.php    2016-06-22 21:17:23 UTC (rev 10895)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -374,4 +374,91 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $expected_commenter = array( $u3 );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( $expected_commenter, wp_list_pluck( $u2_notifications, 'secondary_item_id' ) );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       /**
+        * @ticket BP7135
+        */
+       public function test_activity_reply_notifications_for_blog_comment_to_activity_comment_sync() {
+               $old_user = get_current_user_id();
+               $u1 = $this->factory->user->create();
+               $u2 = $this->factory->user->create();
+               $u3 = $this->factory->user->create();
+
+               $this->set_current_user( $u1 );
+               $userdata = get_userdata( $u1 );
+
+               // let's use activity comments instead of single "new_blog_comment" activity items
+               add_filter( 'bp_disable_blogforum_comments', '__return_false' );
+
+               // Silence comment flood errors.
+               add_filter( 'comment_flood_filter', '__return_false' );
+
+               // create the blog post
+               $post_id = $this->factory->post->create( array(
+                       'post_status' => 'publish',
+                       'post_type'   => 'post',
+                       'post_title'  => 'Test post',
+               ) );
+
+               $this->set_current_user( $u2 );
+               $userdata = get_userdata( $u2 );
+
+               $c1 = wp_new_comment( array(
+                       'comment_post_ID'      => $post_id,
+                       'comment_author'       => $userdata->user_nicename,
+                       'comment_author_url'   => 'http://buddypress.org',
+                       'comment_author_email' => $userdata->user_email,
+                       'comment_content'      => 'this is a blog comment',
+                       'comment_type'         => '',
+                       'comment_parent'       => 0,
+                       'user_id'              => $u2,
+               ) );
+               // Approve the comment
+               $this->factory->comment->update_object( $c1, array( 'comment_approved' => 1 ) );
+
+               $this->set_current_user( $u3 );
+               $userdata = get_userdata( $u3 );
+
+               $c2 = wp_new_comment( array(
+                       'comment_post_ID'      => $post_id,
+                       'comment_author'       => $userdata->user_nicename,
+                       'comment_author_url'   => 'http://buddypress.org',
+                       'comment_author_email' => $userdata->user_email,
+                       'comment_content'      => 'this is a blog comment',
+                       'comment_type'         => '',
+                       'comment_parent'       => $c1,
+                       'user_id'              => $u3,
+               ) );
+               // Approve the comment
+               $this->factory->comment->update_object( $c2, array( 'comment_approved' => 1 ) );
+
+               // Get activity IDs.
+               $ac1 = get_comment_meta( $c1, 'bp_activity_comment_id', true );
+               $ac2 = get_comment_meta( $c2, 'bp_activity_comment_id', true );
+
+               // Check if notifications exists for user 1.
+               $n1 = BP_Notifications_Notification::get( array(
+                       'component_name' => 'activity',
+                       'user_id'        => $u1
+               ) );
+               $this->assertEquals( 2, count( $n1 ) );
+               $this->assertEquals(
+                       array( $ac1, $ac2 ),
+                       wp_list_pluck( $n1, 'item_id' )
+               );
+
+               // Check if notification exists for user 2.
+               $n2 = BP_Notifications_Notification::get( array(
+                       'component_action' => 'comment_reply',
+                       'item_id'          => $ac2,
+                       'user_id'          => $u2
+               ) );
+               $this->assertNotEmpty( $n2 );
+
+               // Reset.
+               $this->set_current_user( $old_user );
+               remove_filter( 'bp_disable_blogforum_comments', '__return_false' );
+               remove_filter( 'comment_flood_filter', '__return_false' );
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>

</body>
</html>