示例#1
0
 public static function getInstance()
 {
     if (null === self::$classInstance) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
示例#2
0
 public function winkBack($params)
 {
     if (empty($params['messageId'])) {
         throw new ApiResponseErrorException('Message id required');
     }
     $message = MAILBOX_BOL_ConversationService::getInstance()->getMessage($params['messageId']);
     try {
         $winkResult = OW::getEventManager()->call('winks.winkBack', array('userId' => $message->senderId, 'partnerId' => $message->recipientId, 'messageId' => $message->id, 'sendNotification' => true));
         if (!empty($winkResult['result'])) {
             SKANDROID_ABOL_MailboxService::getInstance()->sendWinkNotification($winkResult['partnerId'], $winkResult['userId']);
         }
     } catch (Exception $e) {
         $this->assign('result', array('error' => true, 'message' => $e->getMessage()));
         return;
     }
     if (isset($winkResult['result']) && $winkResult['result'] === false) {
         $this->assign('result', array('error' => true, 'message' => strip_tags($winkResult['msg'])));
     } else {
         $message = MAILBOX_BOL_ConversationService::getInstance()->getMessageDataForApi($message);
         $message = $this->service->prepareMessageList(array($message));
         $this->assign('result', array('error' => false, 'message' => $message[0], 'count' => $this->service->countUnreadMessage($message[0]['convId'], OW::getUser()->getId()), 'billingInfo' => $this->service->getBillingInfo(array(SKANDROID_ABOL_MailboxService::ACTION_READ_CHAT_MESSAGE, SKANDROID_ABOL_MailboxService::ACTION_REPLY_CHAT_MESSAGE, SKANDROID_ABOL_MailboxService::ACTION_READ_MESSAGE, SKANDROID_ABOL_MailboxService::ACTION_REPLY_CHAT_MESSAGE))));
     }
 }
示例#3
0
 public function likeUser($params)
 {
     $userId = OW::getUser()->getId();
     if (empty($params['userId'])) {
         throw new ApiResponseErrorException();
     }
     $oppUserId = (int) $params['userId'];
     $service = SKADATE_BOL_Service::getInstance();
     $result = $service->addSpeedmatchRelation($userId, $oppUserId, 1);
     if ($result) {
         $mutual = $service->isSpeedmatchRelationMutual($userId, $oppUserId);
         if ($mutual) {
             $convId = $service->startSpeedmatchConversation($userId, $oppUserId);
             $this->assign('convId', $convId);
             $activeModes = OW::getEventManager()->call('mailbox.get_active_mode_list');
             if (count($activeModes) === 1 && in_array('mail', $activeModes)) {
                 $list = OW::getEventManager()->call('mailbox.get_chat_user_list', array('userId' => $userId, 'count' => 10));
                 foreach ($list as $conv) {
                     if ($conv['conversationId'] == $convId) {
                         $conversationItem = $conv;
                         break;
                     }
                 }
                 $list = SKANDROID_ABOL_MailboxService::getInstance()->prepareConversationList(array($conversationItem));
                 $this->assign('conversation', $list[0]);
             }
         }
         $this->assign('mutual', $mutual);
     }
     $this->assign('result', $result);
 }
示例#4
0
 public function onMailboxGetNewMessages(OW_Event $event)
 {
     if (!OW::getUser()->isAuthenticated()) {
         return;
     }
     $params = $event->getParams();
     $userId = OW::getUser()->getId();
     $ignoreMessageList = !empty($params['ignoreMessageList']) ? $params['ignoreMessageList'] : array();
     $lastRequestTimestamp = !empty($params['lastRequestTimestamp']) ? (int) $params['lastRequestTimestamp'] : 0;
     $activeModes = OW::getEventManager()->call('mailbox.get_active_mode_list');
     $conversationService = MAILBOX_BOL_ConversationService::getInstance();
     $messages = $conversationService->findUnreadMessagesForApi($userId, $ignoreMessageList, $lastRequestTimestamp, $activeModes);
     if (!empty($messages)) {
         $conversationIdList = array();
         foreach ($messages as $message) {
             if (!in_array($message['convId'], $conversationIdList)) {
                 $conversationIdList[] = $message['convId'];
             }
         }
         $conversations = $conversationService->getChatUserList($userId, 0, count($conversationIdList));
         $event->setData(array('messages' => SKANDROID_ABOL_MailboxService::getInstance()->prepareMessageList($messages), 'list' => SKANDROID_ABOL_MailboxService::getInstance()->prepareConversationList($conversations)));
     }
 }