Only show posts created by authors who are friends of the current user

So I have a function in Wordpress with a plugin that returns a list of friends as an array. The function code is here:

function friends_get_list($tmp_uid, $friend_status=1) {
global $wpdb;

$friend_status = intval($friend_status);
if (($friend_status != 1) && ($friend_status != 0))
$friend_status = 1;

if ( $friends_list = get_transient( 'wpmudev-friends-'. $tmp_uid .'-'. $friend_status ) ) {
return $friends_list;
}

$query = $wpdb->prepare("SELECT friend_user_ID FROM " . $wpdb->base_prefix . "friends WHERE user_ID = %d AND friend_approved = %d",
$tmp_uid, $friend_status);
//echo "query=[". $query ."]
";
$friends_list = $wpdb->get_col($query);
set_transient( 'wpmudev-friends-'. $tmp_uid .'-'. $friend_status, $friends_list, 60 );

return $friends_list;
}
I would then like to call this function to obtain the list of the current users friends and then check this against the authors of the displayed posts. I can do this like so: $friendsIdArray = friends_get_list( get_current_user_id(), 1 ) ; which should return all of the confirmed friends for the current user as long as I reference the function. I then want to include this in the Wordpress query to only show posts created by authors who are friends of the current user. I believe I could use this code to load the results into a variable: $query = new WP_Query( array( 'author' => implode( ",", $friendsIdArray ) ); but am unsure exactly where this should go in the wordpress loop to achieve the desired result. Any help is much appreciated!