Skip to content

Commit

Permalink
WIP - Messages
Browse files Browse the repository at this point in the history
  • Loading branch information
KartikSuthar committed Jan 2, 2025
1 parent ceaed25 commit e6481a6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/bp-messages/classes/class-bp-messages-message.php
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,16 @@ public static function avatar_recipients( $thread_id, $user_id = 0 ) {
$query = "SELECT DISTINCT sender_id FROM {$bp->messages->table_name_messages} WHERE thread_id = %d AND sender_id != %d AND is_deleted = 0 ORDER BY id DESC LIMIT 2";
$retval = $wpdb->get_col( $wpdb->prepare( $query, $thread_id, $user_id ) );

if ( count( $retval ) < 2 ) {
$limit = 2 - count( $retval );
$excluded_id = $retval;
$excluded_id[] = $user_id;
$exclude = implode( ',', wp_parse_id_list( $excluded_id ) );
$query = "SELECT DISTINCT user_id FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d AND user_id NOT IN ({$exclude}) AND is_deleted = 0 ORDER BY id DESC LIMIT {$limit}";
$recepient = $wpdb->get_col( $wpdb->prepare( $query, $thread_id ) );
$retval = array_merge( $retval, $recepient );
}

$cache[ $key ] = $retval;

return $retval;
Expand Down

0 comments on commit e6481a6

Please sign in to comment.