'Called when we might need to add user to directory
Args:
room_id (str): room_id that user joined or started being public that
user_id (str)'

@defer.inlineCallbacks
def _handle_new_user(self, room_id, user_id, profile):

    logger.debug('Adding    user    to    dir,    %r', user_id)
    row = (yield self.store.get_user_in_directory(user_id))
    if (not row):
        (yield self.store.add_profiles_to_user_dir(room_id, {user_id: profile}))
    is_public = (yield self.store.is_room_world_readable_or_publicly_joinable(room_id))
    if is_public:
        row = (yield self.store.get_user_in_public_room(user_id))
        if (not row):
            (yield self.store.add_users_to_public_room(room_id, [user_id]))
    else:
        logger.debug('Not    adding    user    to    public    dir,    %r', user_id)
    users_with_profile = (yield self.state.get_current_user_in_room(room_id))
    to_insert = set()
    to_update = set()
    is_appservice = self.store.get_if_app_services_interested_in_user(user_id)
    if (self.is_mine_id(user_id) and (not is_appservice)):
        user_ids_shared = (yield self.store.get_users_who_share_room_from_dir(user_id))
        for other_user_id in users_with_profile:
            if (user_id == other_user_id):
                continue
            shared_is_private = user_ids_shared.get(other_user_id)
            if (shared_is_private is True):
                continue
            elif (shared_is_private is False):
                if (not is_public):
                    to_update.add((user_id, other_user_id))
            elif (shared_is_private is None):
                to_insert.add((user_id, other_user_id))
    for other_user_id in users_with_profile:
        if (user_id == other_user_id):
            continue
        is_appservice = self.store.get_if_app_services_interested_in_user(other_user_id)
        if (self.is_mine_id(other_user_id) and (not is_appservice)):
            shared_is_private = (yield self.store.get_if_users_share_a_room(other_user_id, user_id))
            if (shared_is_private is True):
                continue
            elif (shared_is_private is False):
                if (not is_public):
                    to_update.add((other_user_id, user_id))
            elif (shared_is_private is None):
                to_insert.add((other_user_id, user_id))
    if to_insert:
        (yield self.store.add_users_who_share_room(room_id, (not is_public), to_insert))
    if to_update:
        (yield self.store.update_users_who_share_room(room_id, (not is_public), to_update))
