Skip to:
Content

Opened 4 years ago

Closed 10 months ago

#2834 closed defect (fixed)

Reply to reply doesn't generate proper BuddyPress notifications

Reported by: jpolakovic Owned by: johnjamesjacoby
Milestone: 2.6 Priority: normal
Severity: normal Version: 2.5
Component: Extend - BuddyPress Keywords: commit
Cc:

Description

There seems to be an error in the bbp_buddypress_add_notification method defined in /includes/extend/buddypress/notifications.php

Whenever a nested reply is created, this piece of code gets evaluated:

// Notify the immediate reply author if not the current reply author
if ( !empty( $reply_to ) && ( $author_id !== $reply_to_item_id ) ) {
        $args['secondary_item_id'] = $reply_to_item_id ;

        bp_notifications_add_notification( $args );
}

You can see the author of the reply the current message replies to is NOT notified - instead, the topic author is notified as the $args['user_id'] stays unchanged. The issue here is that the topic author is notified even in cases when it is them who posts the reply to an existing reply under their topic.

To clarify, here are the steps to reproduce the issue:

  1. User Alice creates a new topic.
  2. User Bob replies under this topic.
  3. User Alice replies to Bob's reply.

Expected outcome:

  1. Alice is notified when Bob replies under her topic.
  2. Bob is notified when Alice replies to his reply.
  3. Alice is not notified when Alice replies under Bob's reply.

Current outcome:

  1. Alice is notified when Bob replies under her topic.
  2. Bob is NOT notified when Alice replies to his reply.
  3. Instead, Alice IS notified when Alice replies under Bob's reply.

I believe something along these lines would be enough to mitigate the issue:

// Notify the immediate reply author if not the current reply author
if ( !empty( $reply_to ) && ( $author_id !== $reply_to_item_id ) ) {
        $args['user_id'] = $reply_to_item_id;
        $args['secondary_item_id'] = $topic_author_id;

        bp_notifications_add_notification( $args );
}

Please let me know if anything is unclear, thanks!

Change History (3)

#1 @netweb
4 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Under Consideration
  • Version changed from 2.5.7 to 2.5

jpolakovic,

Thanks for the great report, everything looks pretty clear to me :)

Related: #2495/r5232

#2 @johnjamesjacoby
10 months ago

  • Keywords commit added; needs-patch removed
  • Milestone changed from Under Consideration to 2.6
  • Owner set to johnjamesjacoby

#3 @johnjamesjacoby
10 months ago

  • Resolution set to fixed
  • Status changed from new to closed

In 6815:

BuddyPress: tweak notifications item IDs to provide a bit more context.

This change also fixes a bug with hierarchical reply notifications.

Props jpolakovic. Fixes #2834.

Note: See TracTickets for help on using tickets.