Ticket #8426: 8426.patch
File 8426.patch, 1.7 KB (added by , 4 years ago) |
---|
-
src/bp-messages/bp-messages-notifications.php
217 217 * @param int $thread_id ID of the thread being marked as read. 218 218 */ 219 219 function bp_messages_mark_notification_on_mark_thread( $thread_id ) { 220 $thread_messages = BP_Messages_Thread::get_messages( $thread_id ); 220 // Get unread PM notifications for the user. 221 $new_pm_notifications = BP_Notifications_Notification::get( 222 array( 223 'user_id' => bp_loggedin_user_id(), 224 'component_name' => buddypress()->messages->id, 225 'component_action' => 'new_message', 226 'is_new' => 1, 227 ) 228 ); 221 229 222 foreach ( $thread_messages as $thread_message ) { 223 bp_notifications_mark_notifications_by_item_id( bp_loggedin_user_id(), $thread_message->id, buddypress()->messages->id, 'new_message' ); 230 // Bail if there are no unread PM notifications for the user. 231 if ( true === empty( $new_pm_notifications ) ) { 232 return; 224 233 } 234 235 $unread_message_ids = wp_list_pluck( $new_pm_notifications, 'item_id' ); 236 $thread_messages = BP_Messages_Thread::get_messages( $thread_id ); 237 238 // Get the unread message ids for this thread only. 239 $message_ids = array_intersect( $unread_message_ids, wp_list_pluck( $thread_messages, 'id' ) ); 240 241 foreach ( $message_ids as $message_id ) { 242 bp_notifications_mark_notifications_by_item_id( bp_loggedin_user_id(), $message_id, buddypress()->messages->id, 'new_message' ); 243 } 225 244 } 226 245 add_action( 'messages_thread_mark_as_read', 'bp_messages_mark_notification_on_mark_thread' ); 227 246