function destroy($rmt = false)
    {
        $this->outer_template = null;

        if(!isset($_SESSION['active_user']))
            redirect_to(make_url('users', 'login'));

        if(!isset($_POST['Submit']))
            redirect_to(make_url('messages'));

        $local_id = $_SESSION['active_user']['id'];

        $rel = instance_model('relations');
        $usr = instance_model('users');
        if($rmt == false)
            $rmt = instance_model('remotes');

    // Get local user
        $user = $usr->get_user_by_id($local_id); 

        if($user == array())
            throw new no_such_user_exception();

    // get user being followed
        $flw_user = $rel->get_following_by_id($local_id, $_POST['id']);

        if($flw_user == array())
            throw new no_such_user_exception();

    // Send remove ping
        $response = $rmt->send_ping($flw_user[0]['Relation_pingback'],
            'remove', $flw_user[0]['Remote_name'], 
            $user[0]['Pub_key'], $user[0]['Priv_key'],
            make_follow_url($user[0]['User_name']));

        $response = $rmt->decode_ping_response($response);

    // If ping failed, display error message
        if($response->state == 'fail')
        {
            new_flash('User not found on remote', 1);
            redirect_to(make_url('messages'));
        }

    // remove from local db if successful
        $rel->remove_following_by_id($local_id, $_POST['id']);

        redirect_to(make_url('messages'));
    }
<div class="attributes">
    <p><strong>Messages: </strong><?php echo esc(get_message_count($uid)); ?></p>

    <?php if($fname != ""): ?>
    <p><strong>Name</strong> <?php echo esc($fname) ?></p>
    <?php endif; ?>

    <?php if($location != ""): ?>
    <p><strong>Location</strong> <?php echo esc($location) ?></p>
    <?php endif; ?>

    <?php if($web != ""): ?>
    <p><strong>Web</strong> <a href="<?php echo esc($web) ?>"><?php echo esc($web) ?></a></p>
    <?php endif; ?>

    <?php if($bio != ""): ?>
    <p><strong>Bio</strong> <?php echo esc($bio) ?></p>
    <?php endif; ?>

    <p><strong>Message address</strong> <?php echo esc(make_follow_url($uname)); ?></p>
</div>

<?php display_template('relations', array('uid' => $uid, 'uname' => $uname)); ?>
    function test_make_follow_url()
    {
        $result = make_follow_url('fred');

        $this->assertEquals($result, 'http://localhost/usr/bin/messages/follow/fred');
    }
    function destroy($rmt = false)
    {
        $this->outer_template = null;

        if(!isset($_SESSION['active_user']))
            redirect_to(make_url('users', 'login'));

        if(!isset($_POST['Submit']))
            redirect_to(make_profile_url($_SESSION['active_user']['name']));

        $local_id = $_SESSION['active_user']['id'];

    // Instance models
        $rel = instance_model('relations');
        $usr = instance_model('users');
        $msg = instance_model('messages');
        if($rmt == false)
            $rmt = instance_model('remotes');

    // Get local user
        $user = $usr->get_user_by_id($local_id); 

        if($user == array())
            throw new no_such_user_exception();

    // Get the message
        $message = $msg->get_by_id($local_id, $_POST['id']);

        if($message == array())
        {
            new_flash('Message does not exist', 1);
            redirect_to(make_profile_url($_SESSION['active_user']['name']));
        }

    // Delete
        $msg->delete_by_id($local_id, $_POST['id']);

    // Send pings to update remote caches
        $remote_users = $rel->get_followers($local_id);

        foreach($remote_users as $rmt_user)
            $rmt->send_ping($rmt_user['Message_pingback'], "update", 'null',
                $user[0]['Pub_key'], $user[0]['Priv_key'],
                make_follow_url($_SESSION['active_user']['name']));

    // Redirect
        redirect_to(make_profile_url($_SESSION['active_user']['name']));
    }