Ejemplo n.º 1
0
 public function onAcceptWink(OW_Event $event)
 {
     $params = $event->getParams();
     $activeModeList = $this->service->getActiveModeList();
     $mode = in_array('chat', $activeModeList) ? 'chat' : 'mail';
     $content = json_encode($params['content']);
     if ($mode == 'chat') {
         $conversationId = $this->service->getChatConversationIdWithUserById($params['userId'], $params['partnerId']);
         if (empty($conversationId)) {
             $conversation = $this->service->createChatConversation($params['userId'], $params['partnerId']);
         } else {
             $conversation = $this->service->getConversation($conversationId);
         }
     } else {
         $conversationId = $this->service->getWinkConversationIdWithUserById($params['userId'], $params['partnerId']);
         if (empty($conversationId)) {
             $conversation = $this->service->createConversation($params['userId'], $params['partnerId'], MAILBOX_BOL_ConversationDao::WINK_CONVERSATION_SUBJECT);
         } else {
             $conversation = $this->service->getConversation($conversationId);
         }
     }
     if (!empty($conversation)) {
         $message = $this->service->createMessage($conversation, $params['userId'], $content);
         $this->service->markMessageAsSystem($message->id);
         $this->service->markMessageAuthorizedToRead($message->id);
         $data = array('conversationId' => $conversation->id, 'mode' => $mode);
         $event->setData($data);
     }
 }