2015-11-11 13:10:26 +00:00
|
|
|
class Sessions::Event::ChatStatusAgent < Sessions::Event::ChatBase
|
2015-11-10 14:01:04 +00:00
|
|
|
|
2015-11-11 13:10:26 +00:00
|
|
|
def run
|
2015-11-10 14:01:04 +00:00
|
|
|
|
|
|
|
# check if user has permissions
|
2015-11-25 09:33:39 +00:00
|
|
|
return if !agent_permission_check
|
2015-11-10 14:01:04 +00:00
|
|
|
|
|
|
|
# renew timestamps
|
2015-11-11 13:10:26 +00:00
|
|
|
state = Chat::Agent.state(@session['id'])
|
|
|
|
Chat::Agent.state(@session['id'], state)
|
2015-11-10 14:01:04 +00:00
|
|
|
|
2015-11-11 13:10:26 +00:00
|
|
|
# update recipients of existing sessions
|
|
|
|
Chat::Session.where(state: 'running', user_id: @session['id']).order('created_at ASC').each {|chat_session|
|
|
|
|
chat_session.add_recipient(@client_id, true)
|
|
|
|
}
|
2015-11-10 14:01:04 +00:00
|
|
|
{
|
|
|
|
event: 'chat_status_agent',
|
2015-11-11 13:10:26 +00:00
|
|
|
data: Chat.agent_state(@session['id']),
|
2015-11-10 14:01:04 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|