diff --git a/src/mibew/js/source/chat/modules/chat.js b/src/mibew/js/source/chat/modules/chat.js index c520a640..4181897f 100644 --- a/src/mibew/js/source/chat/modules/chat.js +++ b/src/mibew/js/source/chat/modules/chat.js @@ -203,6 +203,8 @@ "function": "update", "arguments": { "return": { + 'threadState': 'threadState', + 'threadAgentId': 'threadAgentId', 'typing': 'typing', 'canPost': 'canPost' }, @@ -232,6 +234,11 @@ Mibew.Objects.Models.user.set({ canPost: args.canPost || false }); + // Update thread fields + Mibew.Objects.Models.thread.set({ + 'agentId': args.threadAgentId, + 'state': args.threadState + }); } ) ); diff --git a/src/mibew/js/source/default/models/thread.js b/src/mibew/js/source/default/models/thread.js index da542aeb..d91b42d9 100644 --- a/src/mibew/js/source/default/models/thread.js +++ b/src/mibew/js/source/default/models/thread.js @@ -26,7 +26,6 @@ { /** * A list of default model values. - * Inherits values from Mibew.Models.User * @type Object */ defaults: { @@ -48,6 +47,17 @@ */ lastId: 0, + /** + * ID of the user related with the chat. + * @type String + */ + userId: null, + + /** + * ID of the agent related with the chat. + */ + agentId: null, + /** * Thread's state * @type Number diff --git a/src/mibew/libs/chat.php b/src/mibew/libs/chat.php index 71c203a6..b8709dfe 100644 --- a/src/mibew/libs/chat.php +++ b/src/mibew/libs/chat.php @@ -433,7 +433,9 @@ function setup_chatview(Thread $thread) // Set thread params $data['chat']['thread'] = array( 'id' => $thread->id, - 'token' => $thread->lastToken + 'token' => $thread->lastToken, + 'agentId' => $thread->agentId, + 'userId' => $thread->userId, ); $data['page.title'] = empty($group['vcchattitle']) diff --git a/src/mibew/libs/classes/Mibew/RequestProcessor/ThreadProcessor.php b/src/mibew/libs/classes/Mibew/RequestProcessor/ThreadProcessor.php index d55bfbd0..01e8d2c6 100644 --- a/src/mibew/libs/classes/Mibew/RequestProcessor/ThreadProcessor.php +++ b/src/mibew/libs/classes/Mibew/RequestProcessor/ThreadProcessor.php @@ -265,6 +265,10 @@ class ThreadProcessor extends ClientSideProcessor implements RouterAwareInterfac * message * - 'canPost': indicates if agent(user can post message all the time) * can post the message + * - 'threadState': current state of the thread. See Thread::STATE_* + * constants for details. + * - 'threadAgentId': ID of the agent that is currently related with the + * thread. */ protected function apiUpdate($args) { @@ -310,6 +314,8 @@ class ThreadProcessor extends ClientSideProcessor implements RouterAwareInterfac $can_post = $args['user'] || $operator['operatorid'] == $thread->agentId; return array( + 'threadState' => $thread->state, + 'threadAgentId' => $thread->agentId, 'typing' => $is_typing, 'canPost' => $can_post, ); diff --git a/src/mibew/libs/classes/Mibew/RequestProcessor/UsersProcessor.php b/src/mibew/libs/classes/Mibew/RequestProcessor/UsersProcessor.php index 099900c4..06126b16 100644 --- a/src/mibew/libs/classes/Mibew/RequestProcessor/UsersProcessor.php +++ b/src/mibew/libs/classes/Mibew/RequestProcessor/UsersProcessor.php @@ -319,6 +319,7 @@ class UsersProcessor extends ClientSideProcessor implements AuthenticationManage 'userIp' => $user_ip, 'remote' => $thread->remote, 'userAgent' => get_user_agent_version($thread->userAgent), + 'agentId' => $thread->agentId, 'agentName' => $agent_name, 'canOpen' => $can_open, 'canView' => $can_view, diff --git a/src/mibew/libs/invitation.php b/src/mibew/libs/invitation.php index 88f3eba2..0f6296ef 100644 --- a/src/mibew/libs/invitation.php +++ b/src/mibew/libs/invitation.php @@ -336,6 +336,8 @@ function setup_invitation_view(Thread $thread) $data['invitation']['thread'] = array( 'id' => $thread->id, 'token' => $thread->lastToken, + 'agentId' => $thread->agentId, + 'userId' => $thread->userId, ); $data['invitation']['user'] = array(