public function __construct(dialogue $dialogue, $roleid, $page = 0, $limit = dialogue::PAGINATION_MAX_RESULTS)
 {
     parent::__construct($dialogue, $page, $limit);
     $this->roleid = $roleid;
 }
 /**
  * Get User Action: receives a user's email address and responds with the user's full name
  */
 public function getconversationrecipientAction()
 {
     $this->view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_NO_RENDER);
     $request = new \Phalcon\Http\Request();
     if ($request->isPost()) {
         //The request is post, therefore it is receiving data
         //Data is in JSON format
         $data = json_decode(file_get_contents('php://input'), true);
         //print_r($data);
         $user = users::findFirst(array("conditions" => 'id = :idVal: and apiKey = :keyVal:', 'bind' => array('idVal' => $data['userid'], 'keyVal' => $data['user_api_key'])));
         if ($user) {
             $conversation = conversations::findFirst(array("conditions" => 'id = :idVal', "bind" => array("idVal" => $data['targetID'])));
             if ($conversation->user1 == $user->id) {
                 $recipient = $conversation->user1;
             } else {
                 $recipient = $conversation->user2;
             }
             $user = users::findFirst(array("conditions" => "id = :idVal:", "bind" => array("idVal" => $recipient)));
             $array['fullname'] = $user->firstName . " " . $user->lastName;
             echo json_encode($array);
         }
     }
 }