Like JItendra Rana already mentioned, you just send a notification to the author. If all users should get a notification, you must loop through all your users and add a notification to everyone. You get the users with get_users. Here is the modified code to realize it:
function bp_post_published_notification( $post_id, $post ) {
$author_id = $post->post_author; /* Post author ID. */
$users = get_users();
/* Loop all users */
foreach( $users as $user ) {
if ( bp_is_active( 'notifications' ) ) {
bp_notifications_add_notification( array(
'user_id' => $user->ID,
'item_id' => $post_id,
'component_name' => 'custom',
'component_action' => 'custom_action',
'date_notified' => bp_core_current_time(),
'is_new' => 1,
) );
}
}
}
add_action( 'publish_post', 'bp_post_published_notification', 99, 2 );