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); } }
public function onCreateConversation(OW_Event $event) { $params = $event->getParams(); $userId = $params['userId']; $opponentId = $params['opponentId']; $text = $params['text']; $subject = $params['subject']; $userSendMessageIntervalOk = $this->service->checkUserSendMessageInterval($userId); if (!$userSendMessageIntervalOk) { $send_message_interval = (int) OW::getConfig()->getValue('mailbox', 'send_message_interval'); throw new InvalidArgumentException(OW::getLanguage()->text('mailbox', 'feedback_send_message_interval_exceed', array('send_message_interval' => $send_message_interval))); } $conversation = $this->service->createConversation($userId, $opponentId, $subject, $text); $event->setData($conversation); return $conversation; }