Ejemplo n.º 1
0
 public function updateWithData($params)
 {
     if (!isset($params['lastRequestTimestamp'])) {
         return;
     }
     if ((int) $params['lastRequestTimestamp'] == 0) {
         $params['lastRequestTimestamp'] = time();
     }
     /***************************************************************************************************************/
     if (!empty($params['readMessageList'])) {
         $readMessageIdList = array();
         foreach ($params['readMessageList'] as $message) {
             $readMessageIdList[] = $message["id"];
         }
         $this->conversationService->markMessageIdListRead($readMessageIdList);
     }
     /***************************************************************************************************************/
     $ignoreMessageList = array();
     if (!empty($params['ignoreMessageList'])) {
         foreach ($params['ignoreMessageList'] as $message) {
             $ignoreMessageList[] = $message["id"];
         }
     }
     $m = $this->conversationService->findUnreadMessagesForApi($this->userId, $ignoreMessageList, $params['lastRequestTimestamp']);
     $this->setObject('messageList', $m);
     /***************************************************************************************************************/
     if (!isset($params['conversationListLength'])) {
         $params['conversationListLength'] = 0;
     }
     //        $count = $this->conversationService->countConversationListByUserId($this->userId);
     //
     //        if ((int)$params['conversationListLength'] != $count)
     //        {
     //            $list = $this->conversationService->getConversationListByUserId($this->userId);
     //            $this->setObject('conversationList', $list);
     //        }
     if (count($m) > 0) {
         $list = $this->conversationService->getChatUserList($this->userId, 0, 10);
         //TODO specify limits
         $this->setObject('conversationList', $list);
     }
     $this->setObject('lastRequestTimestamp', time());
 }