public function run()
 {
     $filter = new ConversationMessagesFilter();
     $filter->setUUID($this->uuid);
     $filter->setIdGreater($this->lastId);
     $messages = Reg::get('convMgr')->getConversationMessages($filter);
     if (count($messages) > 0) {
         $this->newMessages = $messages;
         $this->newLastId = $messages[count($messages) - 1]->id;
         $this->setIsAnyData();
     }
 }
 public function correctConversationHasAttachment($uuid, $userId)
 {
     if (empty($userId) or !is_numeric($userId)) {
         throw new InvalidIntegerArgumentException("\$receiverUserId have to be non zero integer.");
     }
     if (empty($uuid) or !is_numeric($uuid)) {
         throw new InvalidIntegerArgumentException("\$uuid have to be non zero integer.");
     }
     // Get Conversation of user
     $conversationFilter = new ConversationFilter();
     $conversationFilter->setUUID($uuid);
     $conversationFilter->setUserId($userId);
     $conversation = $this->getConversation($conversationFilter);
     // Find how much messages with attachments in conversation
     $filter = new ConversationMessagesFilter();
     $filter->setUUID($uuid);
     $filter->setDeletedStatus(ConversationManager::STATUS_DELETED_NO, $userId);
     $filter->setHasAttachment(self::STATUS_HAS_ATTACHMENT_YES);
     if ($conversation->fetchFrom != null) {
         $filter->setIdGreater($conversation->fetchFrom);
     }
     $msgsWithAttachmentsCount = $this->getConversationMessagesCount($filter);
     // Correct has attachment status accordingly
     if ($msgsWithAttachmentsCount == 0 and $conversation->hasAttachment == self::STATUS_HAS_ATTACHMENT_YES) {
         $this->setConversationHasNoAttachment($uuid, $userId);
     } elseif ($msgsWithAttachmentsCount > 0 and $conversation->hasAttachment == self::STATUS_HAS_ATTACHMENT_NO) {
         $this->setConversationHasAttachment($uuid, $userId);
     }
 }
 private function correctConversationReadStatus($uuid, $receiverUserId)
 {
     if (empty($receiverUserId) or !is_numeric($receiverUserId)) {
         throw new InvalidIntegerArgumentException("\$receiverUserId have to be non zero integer.");
     }
     if (empty($uuid) or !is_numeric($uuid)) {
         throw new InvalidIntegerArgumentException("\$uuid have to be non zero integer.");
     }
     // Get Conversation of message receiver
     $conversationFilter = new ConversationFilter();
     $conversationFilter->setUUID($uuid);
     $conversationFilter->setUserId($receiverUserId);
     $conversation = $this->getConversation($conversationFilter);
     $unreadFilter = new ConversationMessagesFilter();
     $unreadFilter->setReceiverId($receiverUserId);
     $unreadFilter->setUUID($uuid);
     if ($conversation->fetchFrom != null) {
         $unreadFilter->setIdGreater($conversation->fetchFrom);
     }
     $unreadFilter->setReadStatus(self::STATUS_READ_UNREAD);
     $unreadsCount = $this->getConversationMessagesCount($unreadFilter);
     if ($unreadsCount == 0) {
         $this->markConversationAsRead($receiverUserId, $uuid);
     }
 }