Example #1
0
/**
 * Receipt of a friend request message
 * @param object $data
 * @param object $msg
 * @return 
 */
function friend_request_receive(&$data, &$msg)
{
    // allow only if the server is trusted
    if (!$msg->validateSignature()) {
        return true;
    }
    $con = new HubbubConnection($msg->ownerEntity->key(), $msg->authorEntity->key());
    $usr = new HubbubUser($msg->ownerEntity->key());
    WriteToFile('log/activity.log', $data['msgid'] . ' friend_request received' . chr(10));
    h2_audit_log('msg/friend_request/rcv', array('me' => $msg->ownerEntity->key(), 'sender' => $msg->authorEntity->key()), $data['msgid']);
    switch ($con->status()) {
        case 'req.sent':
            // if we already sent a request to them, complete the process
            $con->status('friend');
            $usr->notify('friend/added', $msg->authorEntity);
            $msg->response['comment'] = 'status updated to {friend}';
            break;
        case 'undefined':
            $con->status('req.rcv');
            $usr->notify('friend/request', $msg->authorEntity);
            $msg->response['comment'] = 'status updated to {received}';
            break;
        default:
            $msg->response['comment'] = 'status not updated';
            break;
    }
    $msg->ok();
    return true;
}
Example #2
0
 function status($status = null)
 {
     if ($status != null) {
         h2_audit_log('connection/status', array('new' => $status, 'old' => $this->ds['c_status']), $this->ds['c_key'] . '/' . $this->ds['c_from'] . ':' . $this->ds['c_to']);
         $this->ds['c_status'] = $status;
         $this->save();
     }
     return getDefault($this->ds['c_status'], 'undefined');
 }