Add "userId" and "agentId" fields to thread at client side

This commit is contained in:
Dmitriy Simushev 2014-11-05 14:15:18 +00:00
parent 3984c260b0
commit 3dd80070c7
6 changed files with 30 additions and 2 deletions

View File

@ -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
});
}
)
);

View File

@ -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

View File

@ -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'])

View File

@ -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,
);

View File

@ -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,

View File

@ -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(